public void AddAddressGetTest() { var controller = new AccountsController(); var result = (PartialViewResult)controller.AddAddress(); Assert.IsInstanceOfType(result, typeof(PartialViewResult)); Assert.AreEqual("AddAddress", result.ViewName); }
public void AddAddressExceptionTest() { var mockMemberDal = new MockMemberDal() { ThrowError = true }; var controller = new AccountsController(mockMemberDal, new MockRentalDal()); var result = (ViewResult)controller.AddAddress(new Address()); Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual("Profile", result.ViewName); Assert.AreEqual("Uh-oh something went wrong", result.ViewData["Error"]); }
public void AddAddressValidTest() { HomeController.CurrentUser = new Member(); var mockMemberDal = new MockMemberDal() { ThrowError = false }; var controller = new AccountsController(mockMemberDal, new MockRentalDal()); var result = (ViewResult)controller.AddAddress(new Address()); Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual("Profile", result.ViewName); }
public void AddAddressInvalidTest() { var mockMemberDal = new MockMemberDal() { ThrowError = false }; var controller = new AccountsController(mockMemberDal, new MockRentalDal()); controller.ModelState.AddModelError("error", "error"); var result = (ViewResult)controller.AddAddress(new Address()); Assert.IsInstanceOfType(result, typeof(ViewResult)); Assert.AreEqual("Profile", result.ViewName); Assert.AreEqual("Invalid Address", result.ViewData["Error"]); }