public async Task EditGetAction_UpdateModelFromService() { // Arrange // Act var result = await validController.Edit(entity.Id); // Assert mock.Verify(a => a.GetAsync(entity.Id, true)); }
public void CanInitEdit() { // Establish Context var viewModel = new PersonFormViewModel(); _personManagementService.Expect(r => r.CreateFormViewModelFor(1)) .Return(viewModel); // Act ViewResult result = _peopleController.Edit(1).AssertViewRendered(); // Assert result.ViewData.Model.ShouldNotBeNull(); (result.ViewData.Model as PersonFormViewModel).ShouldNotBeNull(); }
public void EditReturns404ForUnknownPersonId() { var controller = new PeopleController(new FakePeopleRepository(), null); var result = controller.Edit(-1) as ActionResult; result.Should().BeOfType <HttpNotFoundResult>(); }
public async void PeopleEditNotFound() { PeopleController peopleController = new PeopleController(context: null); var result = await peopleController.Edit(null); Assert.IsType <NotFoundResult>(result); }
public void Edit() { const int personId = 7; var controller = new PeopleController(new FakePeopleRepository(), null); var result = controller.Edit(personId) as ViewResult; result.Model.Should().BeOfType <CreateAndEditPerson>(); ((CreateAndEditPerson)result.Model).Id.Should().Be(personId); }
public async Task EditPostAction_ModelError_ReturnsSameModel() { // Arrange // Act var result = await notValidController.Edit(entity.Id, personViewModel) as ViewResult; // Assert Assert.Equal(personViewModel, result.Model); }
public async void PeopleEditNotFoundWithPeople() { PeopleController peopleController = new PeopleController(context: null); People people = new People { Id = 0 }; var result = await peopleController.Edit(-99, people); Assert.IsType <NotFoundResult>(result); }
public void EditSaved() { // Arrange PeopleController controller = new PeopleController(); People PeopleBefore = new People(); PeopleBefore = db.People.Where(w => w.ID == 5).First(); var PeopleBeforeFirstName = PeopleBefore.FirstName; PeopleBefore.FirstName = "Brian"; // Act RedirectToRouteResult result = (RedirectToRouteResult)controller.Edit(PeopleBefore, null); People PeopleAfter = db.People.Where(w => w.ID == 5).First(); // Assert Assert.AreNotEqual(PeopleBeforeFirstName, PeopleAfter.FirstName); }
public void editTest() { ActionResult result = pc.Edit(1); // NUnit.Framework.Assert.IsInstanceOf(result.GetType(), typeof(ViewResult)); var vResult = result as ViewResult; var prn = new Person(); prn.FirstName = "Bob"; prn.LastName = "Nelson"; if (vResult != null) { // Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsInstanceOfType(vResult.Model, typeof(PeopleSearch.Models.Person)); var model = vResult.Model as Person; if (model != null) { Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(prn.FirstName, model.FirstName); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(prn.LastName, model.LastName); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(prn.Address, model.Address); } } }