mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-22 23:15:20 +00:00
tests run...need parallel none
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SharpCompress.Archive;
|
||||
using SharpCompress.Archive.GZip;
|
||||
@@ -50,7 +51,7 @@ namespace SharpCompress.Test
|
||||
using (Stream stream = File.Open(Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"), FileMode.Open))
|
||||
using (var archive = GZipArchive.Open(stream))
|
||||
{
|
||||
archive.AddEntry("jpg\\test.jpg", jpg);
|
||||
Assert.Throws<InvalidOperationException>(() => archive.AddEntry("jpg\\test.jpg", jpg));
|
||||
archive.SaveTo(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar.gz"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,14 +43,18 @@ namespace SharpCompress.Test
|
||||
[Fact]
|
||||
public void GZip_Writer_Generic_Bad_Compression()
|
||||
{
|
||||
ResetScratch();
|
||||
using (Stream stream = File.OpenWrite(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar.gz")))
|
||||
using (var writer = WriterFactory.Open(stream, ArchiveType.GZip, CompressionType.BZip2))
|
||||
{
|
||||
writer.Write("Tar.tar", Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar"));
|
||||
}
|
||||
CompareArchivesByPath(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar.gz"),
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"));
|
||||
Assert.Throws<InvalidFormatException>(() =>
|
||||
{
|
||||
ResetScratch();
|
||||
using (Stream stream = File.OpenWrite(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar.gz")))
|
||||
using (var writer = WriterFactory.Open(stream, ArchiveType.GZip, CompressionType.BZip2))
|
||||
{
|
||||
writer.Write("Tar.tar", Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar"));
|
||||
}
|
||||
CompareArchivesByPath(Path.Combine(SCRATCH_FILES_PATH, "Tar.tar.gz"),
|
||||
Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz"));
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,12 +66,11 @@ namespace SharpCompress.Test
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ExpectedException(typeof(IndexOutOfRangeException))]
|
||||
public void SevenZipArchive_BZip2_Split()
|
||||
{
|
||||
ArchiveStreamRead("Original.7z.001", "Original.7z.002",
|
||||
Assert.Throws<IndexOutOfRangeException>(() => ArchiveStreamRead("Original.7z.001", "Original.7z.002",
|
||||
"Original.7z.003", "Original.7z.004", "Original.7z.005",
|
||||
"Original.7z.006", "Original.7z.007");
|
||||
"Original.7z.006", "Original.7z.007"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>3b80e585-a2f3-4666-8f69-c7ffda0dd7e5</ProjectGuid>
|
||||
@@ -12,9 +11,11 @@
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -24,10 +24,9 @@ namespace SharpCompress.Test
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ExpectedException(typeof(InvalidFormatException))]
|
||||
public void Tar_Rar_Write()
|
||||
{
|
||||
Write(CompressionType.Rar, "Zip.ppmd.noEmptyDirs.zip", "Zip.ppmd.noEmptyDirs.zip");
|
||||
Assert.Throws<InvalidFormatException>(() => Write(CompressionType.Rar, "Zip.ppmd.noEmptyDirs.zip", "Zip.ppmd.noEmptyDirs.zip"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using SharpCompress.Common;
|
||||
using SharpCompress.Reader;
|
||||
using Xunit;
|
||||
@@ -9,20 +10,20 @@ namespace SharpCompress.Test
|
||||
{
|
||||
public class TestBase
|
||||
{
|
||||
protected static string SOLUTION_BASE_PATH=null;
|
||||
protected static string TEST_ARCHIVES_PATH;
|
||||
protected static string ORIGINAL_FILES_PATH;
|
||||
protected static string MISC_TEST_FILES_PATH;
|
||||
protected static string SCRATCH_FILES_PATH;
|
||||
protected static string SCRATCH2_FILES_PATH;
|
||||
protected static IEnumerable<string> GetRarArchives()
|
||||
protected string SOLUTION_BASE_PATH=null;
|
||||
protected string TEST_ARCHIVES_PATH;
|
||||
protected string ORIGINAL_FILES_PATH;
|
||||
protected string MISC_TEST_FILES_PATH;
|
||||
protected string SCRATCH_FILES_PATH;
|
||||
protected string SCRATCH2_FILES_PATH;
|
||||
protected IEnumerable<string> GetRarArchives()
|
||||
{
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Rar.none.rar");
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Rar.rar");
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Rar.solid.rar");
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Rar.multi.part01.rar");
|
||||
}
|
||||
protected static IEnumerable<string> GetZipArchives()
|
||||
protected IEnumerable<string> GetZipArchives()
|
||||
{
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.bzip2.dd.zip");
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.bzip2.zip");
|
||||
@@ -35,15 +36,15 @@ namespace SharpCompress.Test
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.ppmd.dd.zip");
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Zip.ppmd.zip");
|
||||
}
|
||||
protected static IEnumerable<string> GetTarArchives()
|
||||
protected IEnumerable<string> GetTarArchives()
|
||||
{
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar");
|
||||
}
|
||||
protected static IEnumerable<string> GetTarBz2Archives()
|
||||
protected IEnumerable<string> GetTarBz2Archives()
|
||||
{
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.bz2");
|
||||
}
|
||||
protected static IEnumerable<string> GetTarGzArchives()
|
||||
protected IEnumerable<string> GetTarGzArchives()
|
||||
{
|
||||
yield return Path.Combine(TEST_ARCHIVES_PATH, "Tar.tar.gz");
|
||||
}
|
||||
@@ -218,12 +219,10 @@ namespace SharpCompress.Test
|
||||
Assert.False(archive2.MoveToNextEntry());
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly object testLock = new object();
|
||||
|
||||
static TestBase()
|
||||
public TestBase()
|
||||
{
|
||||
SOLUTION_BASE_PATH = Path.GetDirectoryName(Path.GetDirectoryName(ctx.TestDir));
|
||||
SOLUTION_BASE_PATH = Path.GetDirectoryName(PlatformServices.Default.Application.ApplicationBasePath);
|
||||
TEST_ARCHIVES_PATH = Path.Combine(SOLUTION_BASE_PATH, "TestArchives", "Archives");
|
||||
ORIGINAL_FILES_PATH = Path.Combine(SOLUTION_BASE_PATH, "TestArchives", "Original");
|
||||
MISC_TEST_FILES_PATH = Path.Combine(SOLUTION_BASE_PATH, "TestArchives", "MiscTest");
|
||||
|
||||
@@ -201,13 +201,12 @@ namespace SharpCompress.Test
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ExpectedException(typeof(ArchiveException))]
|
||||
public void Zip_Create_NoDups()
|
||||
{
|
||||
using (var arc = ZipArchive.Create())
|
||||
{
|
||||
arc.AddEntry("1.txt", new MemoryStream());
|
||||
arc.AddEntry("\\1.txt", new MemoryStream());
|
||||
Assert.Throws<ArchiveException>(() => arc.AddEntry("\\1.txt", new MemoryStream()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -139,23 +139,31 @@ namespace SharpCompress.Test
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ExpectedException(typeof(NotSupportedException))]
|
||||
public void Zip_LZMA_WinzipAES_Read()
|
||||
{
|
||||
ResetScratch();
|
||||
using (Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "Zip.lzma.winzipaes.zip")))
|
||||
using (var reader = ZipReader.Open(stream, "test"))
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
if (!reader.Entry.IsDirectory)
|
||||
{
|
||||
Assert.Equal(reader.Entry.CompressionType, CompressionType.Unknown);
|
||||
reader.WriteEntryToDirectory(SCRATCH_FILES_PATH, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
|
||||
}
|
||||
}
|
||||
}
|
||||
VerifyFiles();
|
||||
Assert.Throws<NotSupportedException>(() =>
|
||||
{
|
||||
ResetScratch();
|
||||
using (
|
||||
Stream stream =
|
||||
File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH,
|
||||
"Zip.lzma.winzipaes.zip")))
|
||||
using (var reader = ZipReader.Open(stream, "test"))
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
if (!reader.Entry.IsDirectory)
|
||||
{
|
||||
Assert.Equal(reader.Entry.CompressionType,
|
||||
CompressionType.Unknown);
|
||||
reader.WriteEntryToDirectory(SCRATCH_FILES_PATH,
|
||||
ExtractOptions.ExtractFullPath
|
||||
| ExtractOptions.Overwrite);
|
||||
}
|
||||
}
|
||||
}
|
||||
VerifyFiles();
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -44,10 +44,9 @@ namespace SharpCompress.Test
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ExpectedException(typeof(InvalidFormatException))]
|
||||
public void Zip_Rar_Write()
|
||||
{
|
||||
Write(CompressionType.Rar, "Zip.ppmd.noEmptyDirs.zip", "Zip.ppmd.noEmptyDirs.zip");
|
||||
Assert.Throws<InvalidFormatException>(() => Write(CompressionType.Rar, "Zip.ppmd.noEmptyDirs.zip", "Zip.ppmd.noEmptyDirs.zip"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
SharpCompress.Test/global.json
Normal file
5
SharpCompress.Test/global.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "1.0.0-rc1-final"
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "SharpCompress.Test Class Library",
|
||||
"authors": [ "adam" ],
|
||||
"tags": [ "" ],
|
||||
"projectUrl": "",
|
||||
"licenseUrl": "",
|
||||
"version": "1.0.0-*",
|
||||
"description": "SharpCompress.Test Class Library",
|
||||
"authors": [ "adam" ],
|
||||
"tags": [ "" ],
|
||||
"projectUrl": "",
|
||||
"licenseUrl": "",
|
||||
"commands": {
|
||||
"test": "xunit.runner.dnx"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"Microsoft.CSharp": "4.0.1-beta-23516",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final",
|
||||
"System.Console": "4.0.0-beta-23516",
|
||||
"System.Collections": "4.0.11-beta-23516",
|
||||
"System.Linq": "4.0.1-beta-23516",
|
||||
@@ -20,6 +24,6 @@
|
||||
"dependencies": {
|
||||
"SharpCompress": "0.11.3",
|
||||
"xunit": "2.1.0",
|
||||
"xunit.runner.visualstudio": "2.1.0"
|
||||
"xunit.runner.dnx": "2.1.0-rc1-build204"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ VisualStudioVersion = 14.0.24720.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F18F1765-4A02-42FD-9BEF-F0E2FCBD9D17}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
SharpCompress.Test\global.json = SharpCompress.Test\global.json
|
||||
NuGet\sharpcompress.nuspec = NuGet\sharpcompress.nuspec
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
||||
Reference in New Issue
Block a user