コード例 #1
0
        public void DeletingAnInexistingGameIdMustRaiseException()
        {
            // Given
            IBoringToeRepository repo = new BoringToeSetRepository();

            // When / Then
            NotExistingValueException excep = Assert.Throws <NotExistingValueException>(() => repo.DeleteGame(1), "Deleting 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");
        }
コード例 #2
0
        public void AddedGameMustNotBeNull()
        {
            // Given
            IBoringToeRepository repo = new BoringToeSetRepository();
            long id;

            // When / Then
            NotValidValueException excep = Assert.Throws <NotValidValueException>(() => id = repo.AddGame(null), "Adding null game must return NotValidValueException");

            Assert.AreEqual(excep.ErrorCode, ErrorCode.NULL_VALUE_NOT_ALLOWED, "Exception's error code must be NULL_VALUE_NOT_ALLOWED");
        }
コード例 #3
0
        public void FirstGameAddMustReturn1()
        {
            // Given
            TicTacToeImpl        game = new TicTacToeImpl();
            IBoringToeRepository repo = new BoringToeSetRepository();
            long id;

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

            // Then
            Assert.IsTrue(id == 1, "First game's ID must be 1");
        }
コード例 #4
0
        public void AfterAddingAGameItMustBeAccessableByGuid()
        {
            // Given
            IBoringToeRepository repo = new BoringToeSetRepository();
            long       id;
            ITicTacToe game = new TicTacToeImpl();
            ITicTacToe testGame;

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

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

            // When
            id = repo.AddGame(game1);

            // Then
            DuplicatedValueException excep = Assert.Throws <DuplicatedValueException>(() => id = repo.AddGame(game1), "Must raise an exception if a game already exists");

            Assert.AreEqual(excep.ErrorCode, ErrorCode.VALUE_ALREADY_EXISTS_IN_DATABASE, "Exception's error code must be VALUE_ALREADY_EXISTS_IN_DATABASE");
        }
コード例 #6
0
        public void SecondGameAddMustReturn2()
        {
            // Given
            TicTacToeImpl        game1 = new TicTacToeImpl();
            TicTacToeImpl        game2 = new TicTacToeImpl();
            IBoringToeRepository repo  = new BoringToeSetRepository();
            long id;

            // When
            id = repo.AddGame(game1);
            id = repo.AddGame(game2);

            // Then
            Assert.IsTrue(id == 2, "Second game's ID must be 2");
        }
コード例 #7
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");
        }