コード例 #1
0
        public void AfterAddingAGameItMustBeAccessableById()
        {
            // Given
            IBoringToeRepository repo = new BoringToeSetRepository();
            long       id;
            ITicTacToe game = new TicTacToeImpl();
            ITicTacToe testGame;

            // When
            id       = repo.AddGame(game);
            testGame = repo.GetGameById(id);

            // Then
            Assert.AreEqual(game, testGame, "Returned game must be the same as added one");
        }
コード例 #2
0
        public void GettingADeletedGameMustRaiseException()
        {
            // Given
            IBoringToeRepository repo      = new BoringToeSetRepository();
            TicTacToeImpl        TicTacToe = new TicTacToeImpl();
            long id;

            // When
            id = repo.AddGame(TicTacToe);
            repo.DeleteGame(id);

            // When / Then
            NotExistingValueException excep = Assert.Throws <NotExistingValueException>(() => repo.GetGameById(id), "Getting an inexisting game must raise an exception");

            Assert.AreEqual(excep.ErrorCode, ErrorCode.VALUE_NOT_EXISTING_IN_DATABASE, "Error code must be VALUE_NOT_EXISTING_IN_DATABASE");
        }
コード例 #3
0
        public void GettingAnInexistingGameIdMustRaiseException()
        {
            // Given
            IBoringToeRepository repo = new BoringToeSetRepository();

            // When / Then
            NotExistingValueException excep = Assert.Throws <NotExistingValueException>(() => repo.GetGameById(1), "Getting an inexisting game must raise an exception");

            Assert.AreEqual(excep.ErrorCode, ErrorCode.VALUE_NOT_EXISTING_IN_DATABASE, "Error code must be VALUE_NOT_EXISTING_IN_DATABASE");
        }