convert to blazor server side render
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Shogi.Domain.ValueObjects;
|
||||
using Shogi.Domain.ValueObjects.Movement;
|
||||
using Shogi.Domains.ValueObjects;
|
||||
using Shogi.Domains.ValueObjects.Movement;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
namespace UnitTests;
|
||||
@@ -21,11 +22,11 @@ public class RookShould
|
||||
public void Player1_HasCorrectMoveSet()
|
||||
{
|
||||
var moveSet = rook1.MoveSet;
|
||||
moveSet.Should().HaveCount(4);
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Forward, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Left, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Right, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Backward, Distance.MultiStep));
|
||||
Assert.Equal(4, moveSet.Count);
|
||||
Assert.Contains(new Path(Direction.Forward, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Left, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Right, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Backward, Distance.MultiStep), moveSet);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -33,30 +34,30 @@ public class RookShould
|
||||
{
|
||||
// Arrange
|
||||
rook1.Promote();
|
||||
rook1.IsPromoted.Should().BeTrue();
|
||||
Assert.True(rook1.IsPromoted);
|
||||
|
||||
// Assert
|
||||
var moveSet = rook1.MoveSet;
|
||||
moveSet.Should().HaveCount(8);
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Forward, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Left, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Right, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Backward, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.ForwardLeft, Distance.OneStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.BackwardLeft, Distance.OneStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.ForwardRight, Distance.OneStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.BackwardRight, Distance.OneStep));
|
||||
Assert.Equal(8, moveSet.Count);
|
||||
Assert.Contains(new Path(Direction.Forward, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Left, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Right, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Backward, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.ForwardLeft, Distance.OneStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.BackwardLeft, Distance.OneStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.ForwardRight, Distance.OneStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.BackwardRight, Distance.OneStep), moveSet);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Player2_HasCorrectMoveSet()
|
||||
{
|
||||
var moveSet = rook2.MoveSet;
|
||||
moveSet.Should().HaveCount(4);
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Forward, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Left, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Right, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Backward, Distance.MultiStep));
|
||||
Assert.Equal(4, moveSet.Count);
|
||||
Assert.Contains(new Path(Direction.Forward, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Left, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Right, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Backward, Distance.MultiStep), moveSet);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -64,23 +65,22 @@ public class RookShould
|
||||
{
|
||||
// Arrange
|
||||
rook2.Promote();
|
||||
rook2.IsPromoted.Should().BeTrue();
|
||||
Assert.True(rook2.IsPromoted);
|
||||
|
||||
// Assert
|
||||
var moveSet = rook2.MoveSet;
|
||||
moveSet.Should().HaveCount(8);
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Forward, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Left, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Right, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.Backward, Distance.MultiStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.ForwardLeft, Distance.OneStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.BackwardLeft, Distance.OneStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.ForwardRight, Distance.OneStep));
|
||||
moveSet.Should().ContainEquivalentOf(new Path(Direction.BackwardRight, Distance.OneStep));
|
||||
Assert.Equal(8, moveSet.Count);
|
||||
Assert.Contains(new Path(Direction.Forward, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Left, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Right, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.Backward, Distance.MultiStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.ForwardLeft, Distance.OneStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.BackwardLeft, Distance.OneStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.ForwardRight, Distance.OneStep), moveSet);
|
||||
Assert.Contains(new Path(Direction.BackwardRight, Distance.OneStep), moveSet);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private readonly Rook rookPlayer1;
|
||||
|
||||
public RookShould()
|
||||
@@ -91,11 +91,11 @@ public class RookShould
|
||||
[Fact]
|
||||
public void Promote()
|
||||
{
|
||||
rookPlayer1.IsPromoted.Should().BeFalse();
|
||||
rookPlayer1.CanPromote.Should().BeTrue();
|
||||
Assert.False(rookPlayer1.IsPromoted);
|
||||
Assert.True(rookPlayer1.CanPromote);
|
||||
rookPlayer1.Promote();
|
||||
rookPlayer1.IsPromoted.Should().BeTrue();
|
||||
rookPlayer1.CanPromote.Should().BeFalse();
|
||||
Assert.True(rookPlayer1.IsPromoted);
|
||||
Assert.False(rookPlayer1.CanPromote);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -104,15 +104,15 @@ public class RookShould
|
||||
Vector2 start = new(0, 0);
|
||||
Vector2 end = new(0, 5);
|
||||
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end);
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end).ToList();
|
||||
|
||||
rookPlayer1.IsPromoted.Should().BeFalse();
|
||||
steps.Should().HaveCount(5);
|
||||
steps.Should().Contain(new Vector2(0, 1));
|
||||
steps.Should().Contain(new Vector2(0, 2));
|
||||
steps.Should().Contain(new Vector2(0, 3));
|
||||
steps.Should().Contain(new Vector2(0, 4));
|
||||
steps.Should().Contain(new Vector2(0, 5));
|
||||
Assert.False(rookPlayer1.IsPromoted);
|
||||
Assert.Equal(5, steps.Count);
|
||||
Assert.Contains(new Vector2(0, 1), steps);
|
||||
Assert.Contains(new Vector2(0, 2), steps);
|
||||
Assert.Contains(new Vector2(0, 3), steps);
|
||||
Assert.Contains(new Vector2(0, 4), steps);
|
||||
Assert.Contains(new Vector2(0, 5), steps);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -121,10 +121,10 @@ public class RookShould
|
||||
Vector2 start = new(0, 0);
|
||||
Vector2 end = new(1, 1);
|
||||
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end);
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end).ToList();
|
||||
|
||||
rookPlayer1.IsPromoted.Should().BeFalse();
|
||||
steps.Should().BeEmpty();
|
||||
Assert.False(rookPlayer1.IsPromoted);
|
||||
Assert.Empty(steps);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -134,15 +134,15 @@ public class RookShould
|
||||
Vector2 end = new(0, 5);
|
||||
rookPlayer1.Promote();
|
||||
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end);
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end).ToList();
|
||||
|
||||
rookPlayer1.IsPromoted.Should().BeTrue();
|
||||
steps.Should().HaveCount(5);
|
||||
steps.Should().Contain(new Vector2(0, 1));
|
||||
steps.Should().Contain(new Vector2(0, 2));
|
||||
steps.Should().Contain(new Vector2(0, 3));
|
||||
steps.Should().Contain(new Vector2(0, 4));
|
||||
steps.Should().Contain(new Vector2(0, 5));
|
||||
Assert.True(rookPlayer1.IsPromoted);
|
||||
Assert.Equal(5, steps.Count);
|
||||
Assert.Contains(new Vector2(0, 1), steps);
|
||||
Assert.Contains(new Vector2(0, 2), steps);
|
||||
Assert.Contains(new Vector2(0, 3), steps);
|
||||
Assert.Contains(new Vector2(0, 4), steps);
|
||||
Assert.Contains(new Vector2(0, 5), steps);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -152,11 +152,11 @@ public class RookShould
|
||||
Vector2 end = new(1, 1);
|
||||
rookPlayer1.Promote();
|
||||
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end);
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end).ToList();
|
||||
|
||||
rookPlayer1.IsPromoted.Should().BeTrue();
|
||||
steps.Should().HaveCount(1);
|
||||
steps.Should().Contain(new Vector2(1, 1));
|
||||
Assert.True(rookPlayer1.IsPromoted);
|
||||
Assert.Single(steps);
|
||||
Assert.Contains(new Vector2(1, 1), steps);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -165,15 +165,15 @@ public class RookShould
|
||||
Vector2 start = new(0, 0);
|
||||
Vector2 end = new(0, 5);
|
||||
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end);
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end).ToList();
|
||||
|
||||
rookPlayer1.IsPromoted.Should().BeFalse();
|
||||
steps.Should().HaveCount(5);
|
||||
steps.Should().Contain(new Vector2(0, 1));
|
||||
steps.Should().Contain(new Vector2(0, 2));
|
||||
steps.Should().Contain(new Vector2(0, 3));
|
||||
steps.Should().Contain(new Vector2(0, 4));
|
||||
steps.Should().Contain(new Vector2(0, 5));
|
||||
Assert.False(rookPlayer1.IsPromoted);
|
||||
Assert.Equal(5, steps.Count);
|
||||
Assert.Contains(new Vector2(0, 1), steps);
|
||||
Assert.Contains(new Vector2(0, 2), steps);
|
||||
Assert.Contains(new Vector2(0, 3), steps);
|
||||
Assert.Contains(new Vector2(0, 4), steps);
|
||||
Assert.Contains(new Vector2(0, 5), steps);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -182,10 +182,10 @@ public class RookShould
|
||||
Vector2 start = new(0, 0);
|
||||
Vector2 end = new(1, 1);
|
||||
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end);
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end).ToList();
|
||||
|
||||
rookPlayer1.IsPromoted.Should().BeFalse();
|
||||
steps.Should().BeEmpty();
|
||||
Assert.False(rookPlayer1.IsPromoted);
|
||||
Assert.Empty(steps);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -195,15 +195,15 @@ public class RookShould
|
||||
Vector2 end = new(0, 5);
|
||||
rookPlayer1.Promote();
|
||||
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end);
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end).ToList();
|
||||
|
||||
rookPlayer1.IsPromoted.Should().BeTrue();
|
||||
steps.Should().HaveCount(5);
|
||||
steps.Should().Contain(new Vector2(0, 1));
|
||||
steps.Should().Contain(new Vector2(0, 2));
|
||||
steps.Should().Contain(new Vector2(0, 3));
|
||||
steps.Should().Contain(new Vector2(0, 4));
|
||||
steps.Should().Contain(new Vector2(0, 5));
|
||||
Assert.True(rookPlayer1.IsPromoted);
|
||||
Assert.Equal(5, steps.Count);
|
||||
Assert.Contains(new Vector2(0, 1), steps);
|
||||
Assert.Contains(new Vector2(0, 2), steps);
|
||||
Assert.Contains(new Vector2(0, 3), steps);
|
||||
Assert.Contains(new Vector2(0, 4), steps);
|
||||
Assert.Contains(new Vector2(0, 5), steps);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -213,10 +213,10 @@ public class RookShould
|
||||
Vector2 end = new(1, 1);
|
||||
rookPlayer1.Promote();
|
||||
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end);
|
||||
var steps = rookPlayer1.GetPathFromStartToEnd(start, end).ToList();
|
||||
|
||||
rookPlayer1.IsPromoted.Should().BeTrue();
|
||||
steps.Should().HaveCount(1);
|
||||
steps.Should().Contain(new Vector2(1, 1));
|
||||
Assert.True(rookPlayer1.IsPromoted);
|
||||
Assert.Single(steps);
|
||||
Assert.Contains(new Vector2(1, 1), steps);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user