Before changing Piece[,] to Dictionary<string,Piece>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
using AutoFixture;
|
||||
using FluentAssertions;
|
||||
using FluentAssertions.Execution;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
|
||||
using Gameboard.ShogiUI.Sockets.Services.RequestValidators;
|
||||
using Xunit;
|
||||
|
||||
namespace Gameboard.ShogiUI.xUnitTests.RequestValidators
|
||||
{
|
||||
public class MoveRequestValidatorShould
|
||||
{
|
||||
private readonly Fixture fixture;
|
||||
private readonly MoveRequestValidator validator;
|
||||
public MoveRequestValidatorShould()
|
||||
{
|
||||
fixture = new Fixture();
|
||||
validator = new MoveRequestValidator();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PreventInvalidPropertyCombinations()
|
||||
{
|
||||
// Arrange
|
||||
var request = fixture.Create<MoveRequest>();
|
||||
|
||||
// Act
|
||||
var results = validator.Validate(request);
|
||||
|
||||
// Assert
|
||||
using (new AssertionScope())
|
||||
{
|
||||
results.IsValid.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AllowValidPropertyCombinations()
|
||||
{
|
||||
// Arrange
|
||||
var requestWithoutFrom = new MoveRequest()
|
||||
{
|
||||
Action = ClientAction.Move,
|
||||
GameName = "Some game name",
|
||||
Move = new Move()
|
||||
{
|
||||
IsPromotion = false,
|
||||
PieceFromCaptured = WhichPiece.Bishop,
|
||||
To = "A4"
|
||||
}
|
||||
};
|
||||
var requestWithoutPieceFromCaptured = new MoveRequest()
|
||||
{
|
||||
Action = ClientAction.Move,
|
||||
GameName = "Some game name",
|
||||
Move = new Move()
|
||||
{
|
||||
From = "A1",
|
||||
IsPromotion = false,
|
||||
To = "A4"
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
var results = validator.Validate(requestWithoutFrom);
|
||||
var results2 = validator.Validate(requestWithoutPieceFromCaptured);
|
||||
|
||||
// Assert
|
||||
using (new AssertionScope())
|
||||
{
|
||||
results.IsValid.Should().BeTrue();
|
||||
results2.IsValid.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user