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

            //Act
            var r = await c.Edit(2);


            //Assert
            Assert.IsType <NotFoundResult>(r);
        }
Пример #2
0
        public async void EditWrongIdTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new StadiumsController(db);

            var stadiums = new Stadium {
                Stadium_Id = 2, StadiumName = "Ever After", City = "Everett", Team_Id = 1
            };
            //Act
            await c.Create(stadiums);

            var r = await c.Edit(db.Stadium.Find(1).Stadium_Id, stadiums);

            //Assert
            Assert.IsType <NotFoundResult>(r);
        }
Пример #3
0
        public async void EditTest()
        {
            //Arrange
            var    db       = MockDb.CreateMockDb();
            var    c        = new StadiumsController(db);
            string tempName = "ScotiaBank Arena";

            var stadiums = new Stadium {
                Stadium_Id = 2, StadiumName = "Ever After", City = "Everett", Team_Id = 1
            };
            //Act
            await c.Create(stadiums);

            stadiums.StadiumName = tempName;
            var r = await c.Edit(db.Stadium.Find(2).Stadium_Id, stadiums);

            //Assert
            Assert.IsType <RedirectToActionResult>(r);
            Assert.Equal(db.Stadium.Find(2).StadiumName, tempName);
        }
Пример #4
0
        public async void EditPageTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new StadiumsController(db);

            var stadiums = new Stadium {
                Stadium_Id = 2, StadiumName = "Ever After", City = "Everett", Team_Id = 1
            };
            //Act
            await c.Create(stadiums);

            var r = await c.Edit(db.Stadium.Find(2).Stadium_Id);


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

            Assert.Equal(db.Stadium.Find(2).Stadium_Id, model.Stadium_Id);
            Assert.Equal(db.Stadium.Find(2).StadiumName, model.StadiumName);
        }
Пример #5
0
        public async void EditModelStateNotValidTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new StadiumsController(db);

            var stadiums = new Stadium {
                Stadium_Id = 2, City = "Everett", Team_Id = 1
            };


            //Act
            await c.Create(stadiums);

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

            var r = await c.Edit(db.Stadium.Find(2).Stadium_Id, stadiums);

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

            Assert.Equal(stadiums, model);
        }