forked from adamhathcock/sharpcompress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReaderTests.cs
43 lines (40 loc) · 1.49 KB
/
ReaderTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections.Generic;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SharpCompress.Common;
using SharpCompress.Reader;
namespace SharpCompress.Test
{
public class ReaderTests : TestBase
{
protected void Read(string testArchive, CompressionType expectedCompression)
{
testArchive = Path.Combine(TEST_ARCHIVES_PATH, testArchive);
Read(testArchive.AsEnumerable(), expectedCompression);
}
protected void Read(IEnumerable<string> testArchives, CompressionType expectedCompression)
{
foreach (var path in testArchives)
{
using (Stream stream = File.OpenRead(path))
using (IReader reader = ReaderFactory.Open(stream))
{
UseReader(this, reader, expectedCompression);
}
}
}
public static void UseReader(TestBase test, IReader reader, CompressionType expectedCompression)
{
test.ResetScratch();
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
{
Assert.AreEqual(reader.Entry.CompressionType, expectedCompression);
reader.WriteEntryToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
}
}
test.VerifyFiles();
}
}
}