public void ContactUs_return_View() { var controller = new ContactUsController(); var result = controller.Index(); Assert.IsType <ViewResult>(result); }
public void Index_when_saving_feedback_throws_exception_action_index() { //arrange var contact = new Contact(); var controller = new ContactUsController(_contactService, _categoryService, _systemConfigurationService); //act var result = (ViewResult)controller.Index(contact); //assert Assert.AreEqual("Index", result.ViewName); //cleanup }
public void T01_Index() { var contactModel = new ContactModel(); Validate(contactModel); Assert.AreEqual(2, Validate(contactModel).Count, "Contact model validation model failed: count of fail validation is not equal 9"); contactModel.Message = "test message"; contactModel.Email = "*****@*****.**"; Assert.AreEqual(0, Validate(contactModel).Count, $"Contact model validation model failed:\n { string.Join("\n", Validate(contactModel)) }"); var result = _controller.Index("Small", contactModel) as ViewResult; Assert.IsNull(result); }
public void Index_when_model_state_is_invalid_redirect_to_action_index() { //arrange var mock = new Mock <IContactService>(); _contactService = mock.Object; var contact = new Contact(); var controller = new ContactUsController(_contactService, _categoryService, _systemConfigurationService); controller.ModelState.AddModelError("test", "error"); //act var result = (ViewResult)controller.Index(contact); //assert Assert.AreEqual("Index", result.ViewName); //cleanup _contactService = null; }
public void Index_when_model_state_is_valid_redirect_to_action_confirm() { //arrange var mock = new Mock <IContactService>(); _contactService = mock.Object; var contact = new Contact(); var controller = new ContactUsController(_contactService, _categoryService, _systemConfigurationService); controller.ModelState.Clear(); //act var result = (RedirectToRouteResult)controller.Index(contact); //assert Assert.AreEqual("Confirm", result.RouteValues["action"]); //cleanup _contactService = null; }