Skip to content

Commit

Permalink
Refactor and complete unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutuduxf committed Dec 19, 2023
1 parent 2730340 commit 16ef25b
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 24 deletions.
7 changes: 7 additions & 0 deletions Zaabee.Compression.sln
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zaabee.SystemIoCompression"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zaabee.SystemIoCompression.UnitTest", "tests\Zaabee.SystemIoCompression.UnitTest\Zaabee.SystemIoCompression.UnitTest.csproj", "{70D3599E-7CAA-4DE8-826F-DDA211E3FE75}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zaabee.Compressor.Abstractions.UnitTest", "tests\Zaabee.Compressor.Abstractions.UnitTest\Zaabee.Compressor.Abstractions.UnitTest.csproj", "{81529D2A-F446-4046-8792-318D4808503F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -72,6 +74,7 @@ Global
{73E05D79-6F20-4281-B6D2-41049402CBC5} = {5BE4F706-456E-4DF8-A606-69F992835B47}
{41831AEE-A2EE-4248-B231-007AA198C5F1} = {158FA242-DD0C-4482-BD54-4E7EDA9C44CA}
{70D3599E-7CAA-4DE8-826F-DDA211E3FE75} = {5BE4F706-456E-4DF8-A606-69F992835B47}
{81529D2A-F446-4046-8792-318D4808503F} = {5BE4F706-456E-4DF8-A606-69F992835B47}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F9369C2B-0732-46F2-B95A-8F109BFE59A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -154,5 +157,9 @@ Global
{70D3599E-7CAA-4DE8-826F-DDA211E3FE75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70D3599E-7CAA-4DE8-826F-DDA211E3FE75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70D3599E-7CAA-4DE8-826F-DDA211E3FE75}.Release|Any CPU.Build.0 = Release|Any CPU
{81529D2A-F446-4046-8792-318D4808503F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81529D2A-F446-4046-8792-318D4808503F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81529D2A-F446-4046-8792-318D4808503F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81529D2A-F446-4046-8792-318D4808503F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
6 changes: 3 additions & 3 deletions src/Zaabee.Brotli/Zaabee.Brotli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2023.10.0</PackageVersion>
<Version>2023.10.0</Version>
<PackageVersion>2023.10.1</PackageVersion>
<Version>2023.10.1</Version>
<Authors>Mutuduxf</Authors>
<Company>Mutuduxf</Company>
<PackageTags>Zaabee;Brotli.NET;Brotli;Compression</PackageTags>
Expand All @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="Brotli.NET" Version="2.1.1" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.15.6" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.16.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Zaabee.LZ4/Zaabee.LZ4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2023.10.0</PackageVersion>
<Version>2023.10.0</Version>
<PackageVersion>2023.10.1</PackageVersion>
<Version>2023.10.1</Version>
<Authors>Mutuduxf</Authors>
<Company>Mutuduxf</Company>
<PackageTags>Zaabee;K4os.Compression.LZ4;LZ4;Compression</PackageTags>
Expand All @@ -19,7 +19,7 @@
<ItemGroup>
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.6" />
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.3.6" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.15.6" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.16.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Zaabee.LZMA/Zaabee.LZMA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2023.10.0</PackageVersion>
<Version>2023.10.0</Version>
<PackageVersion>2023.10.1</PackageVersion>
<Version>2023.10.1</Version>
<Authors>Mutuduxf</Authors>
<Company>Mutuduxf</Company>
<PackageTags>Zaabee;LZMA-SDK;LZMA;Compression</PackageTags>
Expand All @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="LZMA-SDK" Version="22.1.1" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.15.6" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.16.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Zaabee.SharpZipLib/Zaabee.SharpZipLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2023.10.0</PackageVersion>
<Version>2023.10.0</Version>
<PackageVersion>2023.10.1</PackageVersion>
<Version>2023.10.1</Version>
<Authors>Mutuduxf</Authors>
<Company>Mutuduxf</Company>
<PackageTags>Zaabee;SharpZipLib;BZip2;GZip;Compression</PackageTags>
Expand All @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.15.6" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.16.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Zaabee.Snappy/Zaabee.Snappy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2023.10.0</PackageVersion>
<Version>2023.10.0</Version>
<PackageVersion>2023.10.1</PackageVersion>
<Version>2023.10.1</Version>
<Authors>Mutuduxf</Authors>
<Company>Mutuduxf</Company>
<PackageTags>Zaabee;IronSnappy;Snappy;Compression</PackageTags>
Expand All @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="IronSnappy" Version="1.3.1" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.15.6" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.16.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2023.10.0</PackageVersion>
<Version>2023.10.0</Version>
<PackageVersion>2023.10.1</PackageVersion>
<Version>2023.10.1</Version>
<Authors>Mutuduxf</Authors>
<Company>Mutuduxf</Company>
<PackageTags>Zaabee;System.IO.Compression;Brotli;Deflate;GZip;Compression</PackageTags>
Expand All @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.15.6" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.16.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Zaabee.XZ/Zaabee.XZ.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2023.10.0</PackageVersion>
<Version>2023.10.0</Version>
<PackageVersion>2023.10.1</PackageVersion>
<Version>2023.10.1</Version>
<Authors>Mutuduxf</Authors>
<Company>Mutuduxf</Company>
<PackageTags>Zaabee;XZ.NET-netstandard;XZ;Compression</PackageTags>
Expand All @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="XZ.NET-netstandard" Version="2.0.0.2" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.15.6" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.16.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/Zaabee.Zstd/Zaabee.Zstd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageVersion>2023.10.0</PackageVersion>
<Version>2023.10.0</Version>
<PackageVersion>2023.10.1</PackageVersion>
<Version>2023.10.1</Version>
<Authors>Mutuduxf</Authors>
<Company>Mutuduxf</Company>
<PackageTags>Zaabee;ZstdNet;Zstd;Compression</PackageTags>
Expand All @@ -18,7 +18,7 @@

<ItemGroup>
<PackageReference Include="ZstdNet" Version="1.4.5" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.15.6" />
<PackageReference Include="Zaabee.Compressor.Abstractions" Version="2023.16.0" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions tests/Zaabee.Compressor.Abstractions.UnitTest/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global using TestModel;
global using Xunit;
66 changes: 66 additions & 0 deletions tests/Zaabee.Compressor.Abstractions.UnitTest/UnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
namespace Zaabee.Compressor.Abstractions.UnitTest;

public class UnitTest
{
[Fact]
public void CompressBytesTest()
{
var compressor = new NullCompressor();
var compressedBytes = compressor.Compress(TestConsts.Data);
var decompressedBytes = compressor.Decompress(compressedBytes);
Assert.Equal(TestConsts.Data, decompressedBytes);
}

[Fact]
public void CompressStringTest()
{
var compressor = new NullCompressor();
var compressedBytes = compressor.Compress(TestConsts.Str);
var decompressedStr = compressor.DecompressToString(compressedBytes);
Assert.Equal(TestConsts.Str, decompressedStr);
}

[Fact]
public void CompressStreamTest()
{
var compressor = new NullCompressor();
var ms = new MemoryStream(TestConsts.Data);
var compressedStream = compressor.Compress(ms);
var decompressedMemory = compressor.Decompress(compressedStream);
Assert.Equal(ms.ToArray(), decompressedMemory.ToArray());
}

[Fact]
public void CompressPackToStreamTest()
{
var compressor = new NullCompressor();
var ms = new MemoryStream(TestConsts.Data);
var compressedStream = new MemoryStream();
compressor.Compress(ms, compressedStream);
var decompressedMemory = new MemoryStream();
compressor.Decompress(compressedStream, decompressedMemory);
Assert.Equal(ms.ToArray(), decompressedMemory.ToArray());
}

[Fact]
public async Task CompressStreamTestAsync()
{
var compressor = new NullCompressor();
var ms = new MemoryStream(TestConsts.Data);
var compressedStream = await compressor.CompressAsync(ms);
var decompressedMemory = await compressor.DecompressAsync(compressedStream);
Assert.Equal(ms.ToArray(), decompressedMemory.ToArray());
}

[Fact]
public async Task CompressPackToStreamTestAsync()
{
var compressor = new NullCompressor();
var ms = new MemoryStream(TestConsts.Data);
var compressedStream = new MemoryStream();
await compressor.CompressAsync(ms, compressedStream);
var decompressedMemory = new MemoryStream();
await compressor.DecompressAsync(compressedStream, decompressedMemory);
Assert.Equal(ms.ToArray(), decompressedMemory.ToArray());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;net6.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Zaabee.Compressor.Abstractions\Zaabee.Compressor.Abstractions.csproj" />
<ProjectReference Include="..\TestModel\TestModel.csproj" />
</ItemGroup>

</Project>

0 comments on commit 16ef25b

Please sign in to comment.