57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
|
|
using FluentAssertions;
|
||
|
|
using SIGCM2.Domain.Pricing.WordCounter;
|
||
|
|
|
||
|
|
namespace SIGCM2.Application.Tests.Domain.Pricing.WordCounter;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// PRC-001 — T2.2 Domain unit tests for WordCountResult value object.
|
||
|
|
/// </summary>
|
||
|
|
public sealed class WordCountResultTests
|
||
|
|
{
|
||
|
|
[Fact]
|
||
|
|
public void WordCountResult_RecordEquality_SameValues_AreEqual()
|
||
|
|
{
|
||
|
|
var dictA = new Dictionary<string, int> { ["Currency"] = 1 };
|
||
|
|
var dictB = new Dictionary<string, int> { ["Currency"] = 1 };
|
||
|
|
|
||
|
|
var a = new WordCountResult(3, dictA);
|
||
|
|
var b = new WordCountResult(3, dictB);
|
||
|
|
|
||
|
|
// Records compare by value — TotalWords and SpecialCharCounts ref equality
|
||
|
|
// (not deep dict equality for records), but TotalWords equality is guaranteed.
|
||
|
|
a.TotalWords.Should().Be(b.TotalWords);
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void WordCountResult_SpecialCharCounts_IsIReadOnlyDictionary()
|
||
|
|
{
|
||
|
|
var result = new WordCountResult(0, new Dictionary<string, int>());
|
||
|
|
|
||
|
|
result.SpecialCharCounts.Should().BeAssignableTo<IReadOnlyDictionary<string, int>>();
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void WordCountResult_MissingKey_ReturnsZeroViaGetValueOrDefault()
|
||
|
|
{
|
||
|
|
var result = new WordCountResult(3, new Dictionary<string, int> { ["Currency"] = 1 });
|
||
|
|
|
||
|
|
result.SpecialCharCounts.GetValueOrDefault("Percentage").Should().Be(0);
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void WordCountResult_EmptySpecialCharCounts_ReturnsEmpty()
|
||
|
|
{
|
||
|
|
var result = new WordCountResult(0, new Dictionary<string, int>());
|
||
|
|
|
||
|
|
result.SpecialCharCounts.Should().BeEmpty();
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void WordCountResult_TotalWords_IsCorrect()
|
||
|
|
{
|
||
|
|
var result = new WordCountResult(5, new Dictionary<string, int>());
|
||
|
|
|
||
|
|
result.TotalWords.Should().Be(5);
|
||
|
|
}
|
||
|
|
}
|