Skip to content

Commit 2c9bc61

Browse files
committedJan 30, 2018
Make IntegrationTests run in modern Visual Studio
- Upgrade nuget packages of libzopfli-sharp.tests - Install NUnit3Adapter to make VS recognize NUnit tests - Patch IntegrationTests.cs to use proper path to get file - [Issue] ZopfliStream stucks
1 parent ae7ae6f commit 2c9bc61

File tree

3 files changed

+57
-15
lines changed

3 files changed

+57
-15
lines changed
 

‎libzopfli-sharp.tests/IntegrationTests.cs

+35-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public void Setup()
2626
public void testDeflateStream()
2727
{
2828
// make sure compression works, file should be smaller
29-
byte[] uncompressed = File.ReadAllBytes("files/fp.log");
29+
string sample = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "files", "fp.log");
30+
byte[] uncompressed = File.ReadAllBytes(sample);
3031
int before = uncompressed.Length;
3132
byte[] compressed;
3233
int after = 0;
@@ -67,7 +68,8 @@ public void testDeflateStream()
6768
[Test]
6869
public void testFaviconGzipCompress()
6970
{
70-
byte[] uncompressed = File.ReadAllBytes("files/favicon.ico");
71+
string sample = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "files", "favicon.ico");
72+
byte[] uncompressed = File.ReadAllBytes(sample);
7173
int before = uncompressed.Length;
7274

7375
byte[] compressed;
@@ -79,12 +81,39 @@ public void testFaviconGzipCompress()
7981
after.Should().NotBe(30);
8082
before.Should().BeGreaterThan(after);
8183
}
82-
84+
85+
[Test]
86+
public void testFaviconGZipStreamCompress()
87+
{
88+
string sample = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "files", "favicon.ico");
89+
byte[] uncompressed = File.ReadAllBytes(sample);
90+
int before = uncompressed.Length;
91+
92+
int after = 0;
93+
using (MemoryStream ms = new MemoryStream())
94+
{
95+
using (ZopfliStream zs = new ZopfliStream(ms, ZopfliFormat.ZOPFLI_FORMAT_GZIP, true))
96+
{
97+
zs.Write(uncompressed, 0, uncompressed.Length);
98+
}
99+
100+
// Test if MemoryStream is still leaved open
101+
ms.Position = 0;
102+
byte[] compressed = ms.ToArray();
103+
ms.Length.Should().Equals(compressed.Length);
104+
after = compressed.Length;
105+
}
106+
107+
after.Should().NotBe(30);
108+
before.Should().BeGreaterThan(after);
109+
}
110+
83111
[Test]
84112
public void testGzipStream()
85113
{
86114
// make sure compression works, file should be smaller
87-
byte[] uncompressed = File.ReadAllBytes("files/fp.log");
115+
string sample = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "files", "fp.log");
116+
byte[] uncompressed = File.ReadAllBytes(sample);
88117
int before = uncompressed.Length;
89118
byte[] compressed;
90119
int after = 0;
@@ -127,7 +156,8 @@ public void testGzipStream()
127156
public void testZlibStream()
128157
{
129158
// make sure compression works, file should be smaller
130-
byte[] uncompressed = File.ReadAllBytes("files/fp.log");
159+
string sample = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "files", "fp.log");
160+
byte[] uncompressed = File.ReadAllBytes(sample);
131161
int before = uncompressed.Length;
132162
byte[] compressed;
133163
int after = 0;

‎libzopfli-sharp.tests/libzopfli-sharp.tests.csproj

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" />
34
<PropertyGroup>
45
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
56
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -21,6 +22,8 @@
2122
<SccAuxPath>SAK</SccAuxPath>
2223
<SccProvider>SAK</SccProvider>
2324
<TargetFrameworkProfile />
25+
<NuGetPackageImportStamp>
26+
</NuGetPackageImportStamp>
2427
</PropertyGroup>
2528
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2629
<DebugSymbols>true</DebugSymbols>
@@ -42,15 +45,17 @@
4245
<Prefer32Bit>false</Prefer32Bit>
4346
</PropertyGroup>
4447
<ItemGroup>
45-
<Reference Include="FluentAssertions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
46-
<SpecificVersion>False</SpecificVersion>
47-
<HintPath>..\packages\FluentAssertions.2.1.0.0\lib\net45\FluentAssertions.dll</HintPath>
48+
<Reference Include="DotNetZip, Version=1.10.1.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
49+
<HintPath>..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
4850
</Reference>
49-
<Reference Include="Ionic.Zip">
50-
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
51+
<Reference Include="FluentAssertions, Version=4.19.4.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
52+
<HintPath>..\packages\FluentAssertions.4.19.4\lib\net45\FluentAssertions.dll</HintPath>
5153
</Reference>
52-
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
53-
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
54+
<Reference Include="FluentAssertions.Core, Version=4.19.4.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
55+
<HintPath>..\packages\FluentAssertions.4.19.4\lib\net45\FluentAssertions.Core.dll</HintPath>
56+
</Reference>
57+
<Reference Include="nunit.framework, Version=3.9.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
58+
<HintPath>..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll</HintPath>
5459
</Reference>
5560
<Reference Include="System" />
5661
<Reference Include="System.Drawing" />
@@ -135,6 +140,12 @@ xcopy /s /y "$(SolutionDir)libzopfli-sharp\NativeBinaries\x86\*.*" "$(TargetDir)
135140
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
136141
xcopy /s /y "$(SolutionDir)libzopfli-sharp\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
137142
</PropertyGroup>
143+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
144+
<PropertyGroup>
145+
<ErrorText>이 프로젝트는 이 컴퓨터에 없는 NuGet 패키지를 참조합니다. 해당 패키지를 다운로드하려면 NuGet 패키지 복원을 사용하십시오. 자세한 내용은 http://go.microsoft.com/fwlink/?LinkID=322105를 참조하십시오. 누락된 파일은 {0}입니다.</ErrorText>
146+
</PropertyGroup>
147+
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props'))" />
148+
</Target>
138149
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
139150
Other similar extension points exist, see Microsoft.Common.targets.
140151
<Target Name="BeforeBuild">

‎libzopfli-sharp.tests/packages.config

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="DotNetZip" version="1.9.1.8" targetFramework="net45" />
4-
<package id="FluentAssertions" version="2.1.0.0" targetFramework="net45" />
5-
<package id="NUnit" version="2.6.2" targetFramework="net45" />
3+
<package id="DotNetZip" version="1.10.1" targetFramework="net45" />
4+
<package id="FluentAssertions" version="4.19.4" targetFramework="net45" />
5+
<package id="NUnit" version="3.9.0" targetFramework="net45" />
6+
<package id="NUnit3TestAdapter" version="3.9.0" targetFramework="net45" />
67
</packages>

0 commit comments

Comments
 (0)
Please sign in to comment.