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
1 parent
048158a
commit 597fe04
Showing
9 changed files
with
120 additions
and
43 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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using HouseofCat.Compression; | ||
using HouseofCat.Compression.LZ4; | ||
|
||
namespace Compression.LZ4; | ||
|
||
public class LZCodecTests | ||
{ | ||
[Fact] | ||
public void Encode_Decode_Success() | ||
{ | ||
// Arrange | ||
var provider = new LZ4CodecProvider(); | ||
var source = new byte[] { 1, 2, 3, 4, 5 }; | ||
var target = new byte[20]; | ||
|
||
// Act | ||
var encodedLength = provider.Encode(source, target); | ||
var decodedLength = provider.Decode(target.AsSpan().Slice(0, encodedLength), source.AsSpan()); | ||
|
||
// Assert | ||
Assert.Equal(source.Length, decodedLength); | ||
Assert.Equal(source, source); | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
tests/UnitTests/Compression/Recyclable/RecyclableDeflateTests.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using HouseofCat.Utilities.Errors; | ||
|
||
namespace Utilities; | ||
|
||
public class GuardTests | ||
{ | ||
public GuardTests() | ||
{ } | ||
|
||
[Fact] | ||
public void AgainstNullTest() | ||
{ | ||
var argumentName = "argumentName"; | ||
var argumentValue = "argumentValue"; | ||
|
||
Guard.AgainstNull(argumentValue, argumentName); | ||
Guard.AgainstNull(string.Empty, argumentName); | ||
|
||
Assert.Throws<ArgumentNullException>(() => Guard.AgainstNull(null, argumentName)); | ||
} | ||
|
||
[Fact] | ||
public void AgainstEmptyTest() | ||
{ | ||
var argumentName = "argumentName"; | ||
var argumentValue = new ArraySegment<string>(Array.Empty<string>()); | ||
|
||
Assert.Throws<ArgumentException>(() => Guard.AgainstEmpty(argumentValue, argumentName)); | ||
} | ||
|
||
[Fact] | ||
public void AgainstNullOrEmptyTest() | ||
{ | ||
var argumentName = "argumentName"; | ||
var argumentValue = new List<string> { "NotEmpty" }; | ||
|
||
Guard.AgainstNullOrEmpty(argumentValue, argumentName); | ||
argumentValue.Clear(); | ||
|
||
Assert.Throws<ArgumentException>(() => Guard.AgainstNullOrEmpty(argumentValue, argumentName)); | ||
} | ||
|
||
[Fact] | ||
public void AgainstNullOrEmptyStringTest() | ||
{ | ||
var argumentName = "argumentName"; | ||
var argumentValue = "argumentValue"; | ||
|
||
Guard.AgainstNullOrEmpty(argumentValue, argumentName); | ||
|
||
Assert.Throws<ArgumentException>(() => Guard.AgainstNullOrEmpty(string.Empty, argumentName)); | ||
} | ||
|
||
[Fact] | ||
public void AgainstNullOrEmptyStreamTest() | ||
{ | ||
var argumentName = "argumentName"; | ||
var argumentValue = new MemoryStream(); | ||
|
||
Assert.Throws<ArgumentException>(() => Guard.AgainstNullOrEmpty(argumentValue, argumentName)); | ||
} | ||
|
||
[Fact] | ||
public void AgainstBothNullOrEmptyTest() | ||
{ | ||
var argumentName = "argumentName"; | ||
var argumentValue = "argumentValue"; | ||
var secondArgumentName = "secondArgumentName"; | ||
var secondArgumentValue = "secondArgumentValue"; | ||
|
||
Guard.AgainstBothNullOrEmpty(argumentValue, argumentName, secondArgumentValue, secondArgumentName); | ||
|
||
Assert.Throws<ArgumentException>(() => Guard.AgainstBothNullOrEmpty("", argumentName, "", secondArgumentName)); | ||
} | ||
} |