Files
sharpcompress/tests/SharpCompress.Test/WriterTests.cs

47 lines
1.6 KiB
C#
Raw Permalink Normal View History

using System;
using System.IO;
2015-12-30 11:19:42 +00:00
using SharpCompress.Common;
using SharpCompress.IO;
2016-09-26 11:49:49 +01:00
using SharpCompress.Readers;
using SharpCompress.Writers;
2015-12-30 11:19:42 +00:00
namespace SharpCompress.Test
{
public class WriterTests : TestBase
{
2017-05-19 10:52:49 +01:00
private readonly ArchiveType type;
2015-12-30 11:19:42 +00:00
protected WriterTests(ArchiveType type)
{
this.type = type;
}
protected void Write(CompressionType compressionType, string archive, string archiveToVerifyAgainst)
{
ResetScratch();
using (Stream stream = File.OpenWrite(Path.Combine(SCRATCH2_FILES_PATH, archive)))
{
2018-04-22 11:19:11 +01:00
using (var writer = WriterFactory.Open(stream, type, new WriterOptions(compressionType)
{
2016-09-29 11:10:11 +01:00
LeaveStreamOpen = true
}))
{
writer.WriteAll(ORIGINAL_FILES_PATH, "*", SearchOption.AllDirectories);
}
2015-12-30 11:19:42 +00:00
}
CompareArchivesByPath(Path.Combine(SCRATCH2_FILES_PATH, archive),
Path.Combine(TEST_ARCHIVES_PATH, archiveToVerifyAgainst));
using (Stream stream = File.OpenRead(Path.Combine(SCRATCH2_FILES_PATH, archive)))
using (var reader = ReaderFactory.Open(new NonDisposingStream(stream)))
2015-12-30 11:19:42 +00:00
{
2016-09-27 11:08:54 +01:00
reader.WriteAllToDirectory(SCRATCH_FILES_PATH, new ExtractionOptions()
{
ExtractFullPath = true
});
2015-12-30 11:19:42 +00:00
}
VerifyFiles();
}
}
}