Ejemplo n.º 1
0
        public void CheckDelete()
        {
            // Arranje
            var boardGame = _boardGameService.Get(1);

            // Act
            _boardGameService.Delete(boardGame);

            // Assert
            string expectedMessage = "Game not available.";

            void actAssert() => _boardGameService.Get(boardGame.Id);

            BoardGameServiceException exception = Assert.Throws <BoardGameServiceException>(actAssert);

            Assert.Equal(expectedMessage, exception.Message);
        }
Ejemplo n.º 2
0
        public void CheckCreateWithExceptionReturn()
        {
            // Arranje
            BoardGame newBoardGame = new BoardGame
            {
                Title             = "Candy Land",
                PublishingCompany = "Hasbro",
                MinPlayers        = 2,
                MaxPlayers        = 4,
                Price             = 1.0m
            };

            // Act
            void act() => _boardGameService.Create(newBoardGame);

            // Assert
            string expectedMessage = "It is not possible to register a game with the same title.";
            BoardGameServiceException exception = Assert.Throws <BoardGameServiceException>(act);

            Assert.Equal(expectedMessage, exception.Message);
        }
Ejemplo n.º 3
0
        public void CheckEditWithExceptionReturn()
        {
            // Arranje
            BoardGame updateBoardGame = new BoardGame
            {
                Id                = 5,
                Title             = "Sequence",
                PublishingCompany = "Z-Man Games 2",
                MinPlayers        = 1,
                MaxPlayers        = 4,
                Price             = 10.50m
            };

            // Act
            void act() => _boardGameService.Edit(updateBoardGame);

            // Assert
            string expectedMessage = "It is not possible to register a game with the same title.";
            BoardGameServiceException exception = Assert.Throws <BoardGameServiceException>(act);

            Assert.Equal(expectedMessage, exception.Message);
        }