Пример #1
0
        public void Can_Save_Valid_Changes()
        {
            var mock = new Mock<IGameRepository>();
            var controller = new AdminController(mock.Object);
            var game = new Game {Name = "Test"};
            var result = controller.Edit(game);
            mock.Verify(m => m.SaveGame(game));

            Assert.IsNotInstanceOfType(result, typeof (ViewResult));
        }
Пример #2
0
        public void Can_Edit_game()
        {
            var mock = new Mock<IGameRepository>();
            mock.Setup(m => m.Games).Returns(new List<Game>
            {
                new Game {GameId = 1, Name = "Игра1"},
                new Game {GameId = 2, Name = "Игра2"},
                new Game {GameId = 3, Name = "Игра3"},
                new Game {GameId = 4, Name = "Игра4"},
                new Game {GameId = 5, Name = "Игра5"}
            });

            var controller = new AdminController(mock.Object);

            var game1 = controller.Edit(1).ViewData.Model as Game;
            var game2 = controller.Edit(2).ViewData.Model as Game;
            var game3 = controller.Edit(3).ViewData.Model as Game;

            Assert.AreEqual(1, game1.GameId);
            Assert.AreEqual(2, game2.GameId);
            Assert.AreEqual(3, game3.GameId);
        }
Пример #3
0
        public void Can_Delete_Valid_Games()
        {
            var game = new Game
            {
                GameId = 2,
                Name = "Игра2"
            };

            var mock = new Mock<IGameRepository>();
            mock.Setup(m => m.Games).Returns(new List<Game>
            {
                new Game {GameId = 1, Name = "Игра1"},
                new Game {GameId = 2, Name = "Игра2"},
                new Game {GameId = 3, Name = "Игра3"},
                new Game {GameId = 4, Name = "Игра4"},
                new Game {GameId = 5, Name = "Игра5"}
            });

            var controller = new AdminController(mock.Object);
            controller.Delete(game.GameId);

            mock.Verify(m => m.DeleteGame(game.GameId));
        }