Beispiel #1
0
        public void AddUser_GivenExistingPieceColor_ShouldReturnException()
        {
            var expected = new ChessException("Piece color 'WhitePiece' is already in use");
            var users    = new Users(new List <UserBase> {
                CreatePlayer("test", WhitePiece)
            });

            var actual = users
                         .AddUser("user", WhitePiece)
                         .Match(_ => _, _ => default);

            actual.ShouldBeEquivalentTo(expected);
        }
Beispiel #2
0
        public void MovePiece_GivenInvalidNewPosition_ShouldReturnException()
        {
            var        expected   = new ChessException("Can't move the piece '♙a2'");
            Chessboard chessboard = new List <PieceBase> {
                CreatePawn("a2", WhitePiece)
            };

            var actual = chessboard
                         .MovePiece(CreatePlayer("jr", WhitePiece), CreatePosition("a2"), CreatePosition("b3"))
                         .Match(_ => _, _ => default);

            actual.ShouldBeEquivalentTo(expected);
        }
Beispiel #3
0
        public void MessageDadaMensagemComParametroDeveRetornarMensagem()
        {
            this.exception = new ChessException("Cannot move the piece '{0}'.", "a1");

            this.exception.Message.Should().Be("Cannot move the piece 'a1'.");
        }
Beispiel #4
0
 public static Try <TValue> Failure <TValue>(ChessException exception) => new Try <TValue>(exception);
Beispiel #5
0
 public Try(ChessException failure)
 {
     this.failure = failure;
     this.success = default;
 }
Beispiel #6
0
 internal static Unit ShowError(ChessException exception, bool confirm = false, bool clean = true) => ShowError(exception.Message, confirm, clean);