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); }
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); }
public void MessageDadaMensagemComParametroDeveRetornarMensagem() { this.exception = new ChessException("Cannot move the piece '{0}'.", "a1"); this.exception.Message.Should().Be("Cannot move the piece 'a1'."); }
public static Try <TValue> Failure <TValue>(ChessException exception) => new Try <TValue>(exception);
public Try(ChessException failure) { this.failure = failure; this.success = default; }
internal static Unit ShowError(ChessException exception, bool confirm = false, bool clean = true) => ShowError(exception.Message, confirm, clean);