1.7 ApiKey value type
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
78
tests/FrameProcessor.Tests/ApiKeyTests.cs
Normal file
78
tests/FrameProcessor.Tests/ApiKeyTests.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using FrameProcessor.Domain;
|
||||
|
||||
namespace FrameProcessor.Tests;
|
||||
|
||||
public class ApiKeyTests
|
||||
{
|
||||
[Fact]
|
||||
public void Matches_ReturnsTrue_ForIdenticalKey()
|
||||
{
|
||||
var key = new ApiKey("s3cret-value");
|
||||
Assert.True(key.Matches("s3cret-value"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Matches_ReturnsFalse_ForDifferentKey()
|
||||
{
|
||||
var key = new ApiKey("s3cret-value");
|
||||
Assert.False(key.Matches("wrong"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Matches_ReturnsFalse_ForKeyOfDifferentLength()
|
||||
{
|
||||
var key = new ApiKey("s3cret");
|
||||
Assert.False(key.Matches("s3cret-value"));
|
||||
Assert.False(key.Matches("s3cre"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Matches_ReturnsFalse_ForNull()
|
||||
{
|
||||
var key = new ApiKey("s3cret");
|
||||
Assert.False(key.Matches(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Matches_ReturnsFalse_ForEmptyCandidate_WhenKeyIsNotEmpty()
|
||||
{
|
||||
var key = new ApiKey("s3cret");
|
||||
Assert.False(key.Matches(string.Empty));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Matches_IsCaseSensitive()
|
||||
{
|
||||
var key = new ApiKey("Secret");
|
||||
Assert.False(key.Matches("secret"));
|
||||
Assert.False(key.Matches("SECRET"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Matches_HandlesMultiByteUtf8()
|
||||
{
|
||||
var key = new ApiKey("nyckel-äöå");
|
||||
Assert.True(key.Matches("nyckel-äöå"));
|
||||
Assert.False(key.Matches("nyckel-aoa"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_ThrowsOnNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new ApiKey(null!));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Value_ReturnsConfiguredString()
|
||||
{
|
||||
var key = new ApiKey("abc");
|
||||
Assert.Equal("abc", key.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultStruct_Value_IsEmpty()
|
||||
{
|
||||
var key = default(ApiKey);
|
||||
Assert.Equal(string.Empty, key.Value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user