Пример #1
0
        public async void TestAddInvalidGame()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new GameManagerController(db);

            var game = new Game {
                Description = "Desc 2", DeveloperId = 1, GenreId = 1, ImageUrl = "", MinimumRequirements = "REQ", Price = 29.99m
            };

            c.ModelState.AddModelError("Name", "Required");

            //Act

            var r = await c.Create(game);

            //Assert
            var result = Assert.IsType <ViewResult>(r);
            var model  = Assert.IsAssignableFrom <Game>(result.ViewData.Model);

            Assert.Equal(game, model);
            Assert.IsType <SelectList>(result.ViewData["DeveloperId"]);
            Assert.IsType <SelectList>(result.ViewData["GenreId"]);
        }