示例#1
0
        public void new_should_redirect_if_model_is_valid()
        {
            // Arrange
            var validModel = new AppModel { Name = "test name", Url = "test.com", Description = "test description" };

            // Act
            var controller = new AppController(null, null);
            var view = controller.New(validModel) as RedirectResult;

            // Assert
            Assert.NotNull(view);
            Assert.AreEqual(view.Url, "/user/apps");
            Assert.IsTrue(controller.HasPostAttribute("New", new[] { typeof(AppModel) }), "HttpPost attribute not found or ValidateAntiForgeryToken attribute not added on AppController's New() action method");
        }
示例#2
0
        public void new_should_return_app_model_if_model_is_invalid()
        {
            // Arrange
            var inValidModel = new AppModel { Name = "test name", Url = "test.com" };

            // Act
            var controller = new AppController(null, null);
            var view = controller.New(inValidModel) as ViewResult;

            // Assert
            Assert.NotNull(view);
            Assert.NotNull(view.Model);

            var model = view.Model as AppModel;
            Assert.NotNull(model);

            Assert.IsTrue(controller.HasPostAttribute("New", new[] { typeof(AppModel) }), "HttpPost attribute not found or ValidateAntiForgeryToken attribute not added on AppController's New() action method");
        }