61114ea31b
Creates the 9-project .NET 8 solution (5 src + 4 test) with Marathon.Domain fully implemented: value objects (SportCode, EventId, OddsRate, OddsValue, BetScope hierarchy), enums (Side, BetType, OddsSource, AnomalyKind), and entities (Sport, Country, League, Event, Bet, OddsSnapshot, EventResult, Anomaly) with all invariants enforced in constructors. 96 domain tests pass (FluentAssertions + xUnit). Directory.Build.props and Directory.Packages.props centralise build settings and NuGet versions. Both Marathon.sln and Marathon.slnx are committed; dotnet build Marathon.sln succeeds with 0 warnings/errors.
72 lines
1.8 KiB
C#
72 lines
1.8 KiB
C#
using FluentAssertions;
|
|
using Marathon.Domain.ValueObjects;
|
|
|
|
namespace Marathon.Domain.Tests.ValueObjects;
|
|
|
|
public sealed class BetScopeTests
|
|
{
|
|
[Fact]
|
|
public void MatchScope_Singleton_IsTheSameInstance()
|
|
{
|
|
MatchScope.Instance.Should().BeSameAs(MatchScope.Instance);
|
|
}
|
|
|
|
[Fact]
|
|
public void PeriodScope_CreatesInstance_WhenNumberIsPositive()
|
|
{
|
|
var scope = new PeriodScope(1);
|
|
scope.Number.Should().Be(1);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(0)]
|
|
[InlineData(-1)]
|
|
[InlineData(int.MinValue)]
|
|
public void PeriodScope_ThrowsArgumentOutOfRangeException_WhenNumberIsZeroOrNegative(int number)
|
|
{
|
|
var act = () => new PeriodScope(number);
|
|
act.Should().Throw<ArgumentOutOfRangeException>()
|
|
.WithParameterName("Number");
|
|
}
|
|
|
|
[Fact]
|
|
public void BetScope_PatternMatching_WorksCorrectly()
|
|
{
|
|
BetScope match = MatchScope.Instance;
|
|
BetScope period = new PeriodScope(2);
|
|
|
|
var matchResult = match switch
|
|
{
|
|
MatchScope => "match",
|
|
PeriodScope(var n) => $"period-{n}",
|
|
_ => "other",
|
|
};
|
|
|
|
var periodResult = period switch
|
|
{
|
|
MatchScope => "match",
|
|
PeriodScope(var n) => $"period-{n}",
|
|
_ => "other",
|
|
};
|
|
|
|
matchResult.Should().Be("match");
|
|
periodResult.Should().Be("period-2");
|
|
}
|
|
|
|
[Fact]
|
|
public void PeriodScope_Equality_IsValueBased()
|
|
{
|
|
var a = new PeriodScope(1);
|
|
var b = new PeriodScope(1);
|
|
a.Should().Be(b);
|
|
}
|
|
|
|
[Fact]
|
|
public void MatchScope_And_PeriodScope_AreNotEqual()
|
|
{
|
|
BetScope match = MatchScope.Instance;
|
|
BetScope period = new PeriodScope(1);
|
|
match.Should().NotBe(period);
|
|
}
|
|
}
|