Example #1
0
        public void ContactUs_return_View()
        {
            var controller = new ContactUsController();
            var result     = controller.Index();

            Assert.IsType <ViewResult>(result);
        }
Example #2
0
        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);
        }
Example #4
0
        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;
        }
Example #5
0
        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;
        }