-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
129 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tests/Zaabee.Compressor.Abstractions.UnitTest/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
global using TestModel; | ||
global using Xunit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/Zaabee.Compressor.Abstractions.UnitTest/Zaabee.Compressor.Abstractions.UnitTest.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |