Skip to content

Commit

Permalink
✅ Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marthijn van den Heuvel committed Oct 4, 2024
1 parent 7029073 commit 8b3eab8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Sidio.Text.Base32.Tests/Base32Tests.Hex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ namespace Sidio.Text.Base32.Tests;

public partial class Base32Tests
{
[Fact]
public void DecodeHex_WithNull_ThrowsException()
{
// arrange
string? input = null;

// act
var action = () => Base32.DecodeHex(input!);

// assert
action.Should().Throw<ArgumentNullException>();
}

[Theory]
[ClassData(typeof(Base32HexTestVectors))]
public void DecodeHex_ReturnsByteArray(string input, string base32)
Expand All @@ -18,6 +31,19 @@ public void DecodeHex_ReturnsByteArray(string input, string base32)
var stringResult = Encoding.UTF8.GetString(result);
stringResult.Should().BeEquivalentTo(input);
}

[Fact]
public void EncodeHex_WithNull_ThrowsException()
{
// arrange
byte[]? input = null;

// act
var action = () => Base32.EncodeHex(input!);

// assert
action.Should().Throw<ArgumentNullException>();
}

[Theory]
[ClassData(typeof(Base32HexTestVectors))]
Expand Down
26 changes: 26 additions & 0 deletions src/Sidio.Text.Base32.Tests/Base32Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ namespace Sidio.Text.Base32.Tests;

public partial class Base32Tests
{
[Fact]
public void Decode_WithNull_ThrowsException()
{
// arrange
string? input = null;

// act
var action = () => Base32.Decode(input!);

// assert
action.Should().Throw<ArgumentNullException>();
}

[Theory]
[ClassData(typeof(Base32TestVectors))]
public void Decode_ReturnsByteArray(string input, string base32)
Expand All @@ -19,6 +32,19 @@ public void Decode_ReturnsByteArray(string input, string base32)
stringResult.Should().BeEquivalentTo(input);
}

[Fact]
public void Encode_WithNull_ThrowsException()
{
// arrange
byte[]? input = null;

// act
var action = () => Base32.Encode(input!);

// assert
action.Should().Throw<ArgumentNullException>();
}

[Theory]
[ClassData(typeof(Base32TestVectors))]
public void Encode_ReturnsBase32String(string input, string base32)
Expand Down

0 comments on commit 8b3eab8

Please sign in to comment.