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); }
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); }
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); }
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); }
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); }