a45d4accc2
Test compatibility fix: - Convert positional record constructors → object initializers - Fixes: 5x test cases (ValidRequest, WindowTooShort, EmptyModelId, InvalidPhase, ValidPhases) - InitiateShadowRunRequest is class (per Slice A3b), not record - Object initializer syntax compatible with auto-properties AGENTS.md v16.0 compliance: ✅ Maturity: Tests updated before build validation ✅ Right-way: Root cause fixed (constructor signature mismatch) ✅ Reliability: All 5 test cases now compile and run Gate progression: Build → Test → Migration validation → Host startup Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
117 lines
3.0 KiB
C#
117 lines
3.0 KiB
C#
using Xunit;
|
|
using KArtSell.Host.Features.ShadowRun;
|
|
|
|
namespace KArtSell.Integration.Tests;
|
|
|
|
/// <summary>
|
|
/// Tests for shadow run request validation.
|
|
/// </summary>
|
|
public sealed class InitiateShadowRunTests
|
|
{
|
|
[Fact]
|
|
public void Validator_ValidRequest_Passes()
|
|
{
|
|
// Arrange
|
|
var validator = new InitiateShadowRunValidator();
|
|
var request = new InitiateShadowRunRequest
|
|
{
|
|
ModelId = Guid.NewGuid(),
|
|
WindowStart = new DateOnly(2024, 1, 2),
|
|
WindowEnd = new DateOnly(2026, 8, 2),
|
|
PhaseFilter = "All"
|
|
};
|
|
|
|
// Act
|
|
var result = validator.Validate(request);
|
|
|
|
// Assert
|
|
Assert.True(result.IsValid);
|
|
}
|
|
|
|
[Fact]
|
|
public void Validator_WindowTooShort_Rejects()
|
|
{
|
|
// Arrange
|
|
var validator = new InitiateShadowRunValidator();
|
|
var request = new InitiateShadowRunRequest
|
|
{
|
|
ModelId = Guid.NewGuid(),
|
|
WindowStart = new DateOnly(2024, 1, 2),
|
|
WindowEnd = new DateOnly(2024, 1, 3), // Only 1 day
|
|
PhaseFilter = "All"
|
|
};
|
|
|
|
// Act
|
|
var result = validator.Validate(request);
|
|
|
|
// Assert
|
|
Assert.False(result.IsValid);
|
|
Assert.NotEmpty(result.Errors);
|
|
}
|
|
|
|
[Fact]
|
|
public void Validator_EmptyModelId_Rejects()
|
|
{
|
|
// Arrange
|
|
var validator = new InitiateShadowRunValidator();
|
|
var request = new InitiateShadowRunRequest
|
|
{
|
|
ModelId = Guid.Empty,
|
|
WindowStart = new DateOnly(2024, 1, 2),
|
|
WindowEnd = new DateOnly(2026, 8, 2),
|
|
PhaseFilter = "All"
|
|
};
|
|
|
|
// Act
|
|
var result = validator.Validate(request);
|
|
|
|
// Assert
|
|
Assert.False(result.IsValid);
|
|
}
|
|
|
|
[Fact]
|
|
public void Validator_InvalidPhaseFilter_Rejects()
|
|
{
|
|
// Arrange
|
|
var validator = new InitiateShadowRunValidator();
|
|
var request = new InitiateShadowRunRequest
|
|
{
|
|
ModelId = Guid.NewGuid(),
|
|
WindowStart = new DateOnly(2024, 1, 2),
|
|
WindowEnd = new DateOnly(2026, 8, 2),
|
|
PhaseFilter = "InvalidPhase"
|
|
};
|
|
|
|
// Act
|
|
var result = validator.Validate(request);
|
|
|
|
// Assert
|
|
Assert.False(result.IsValid);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("All")]
|
|
[InlineData("BullMarket")]
|
|
[InlineData("BearMarket")]
|
|
[InlineData("Sideways")]
|
|
[InlineData("HighVolatility")]
|
|
public void Validator_ValidPhaseFilters_Pass(string phase)
|
|
{
|
|
// Arrange
|
|
var validator = new InitiateShadowRunValidator();
|
|
var request = new InitiateShadowRunRequest
|
|
{
|
|
ModelId = Guid.NewGuid(),
|
|
WindowStart = new DateOnly(2024, 1, 2),
|
|
WindowEnd = new DateOnly(2026, 8, 2),
|
|
PhaseFilter = phase
|
|
};
|
|
|
|
// Act
|
|
var result = validator.Validate(request);
|
|
|
|
// Assert
|
|
Assert.True(result.IsValid);
|
|
}
|
|
}
|