Before changing Piece[,] to Dictionary<string,Piece>
This commit is contained in:
17
Gameboard.ShogiUI.xUnitTests/GameShould.cs
Normal file
17
Gameboard.ShogiUI.xUnitTests/GameShould.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using FluentAssertions;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
|
||||
using Xunit;
|
||||
|
||||
namespace Gameboard.ShogiUI.xUnitTests
|
||||
{
|
||||
public class GameShould
|
||||
{
|
||||
[Fact]
|
||||
public void DiscardNullPLayers()
|
||||
{
|
||||
var game = new Game("Test", "P1", null);
|
||||
|
||||
game.Players.Count.Should().Be(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoFixture" Version="4.17.0" />
|
||||
<PackageReference Include="FluentAssertions" Version="5.10.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Gameboard.ShogiUI.Sockets\Gameboard.ShogiUI.Sockets.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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