public void HttpMethodOverrideWithVerbRendersHiddenField() { // Arrange HtmlHelper htmlHelper = new HtmlHelper(new Mock<ViewContext>().Object, GetViewDataContainer(null), new RouteCollection()); ; // Act MvcHtmlString hiddenField = htmlHelper.HttpMethodOverride(HttpVerbs.Delete); // Assert Assert.AreEqual<string>(@"<input name=""X-HTTP-Method-Override"" type=""hidden"" value=""DELETE"" />", hiddenField.ToHtmlString()); }
public void HttpMethodOverrideWithMethodRendersHiddenField() { // Arrange var viewContext = new Mock<ViewContext>().Object; var viewDataContainer = MvcHelper.GetViewDataContainer(null); var htmlHelper = new HtmlHelper(viewContext, viewDataContainer); // Act MvcHtmlString hiddenField = htmlHelper.HttpMethodOverride("PUT"); // Assert Assert.AreEqual<string>(@"<input name=""X-HTTP-Method-Override"" type=""hidden"" value=""PUT"" />", hiddenField.ToHtmlString()); }
public void HttpMethodOverrideWithNullThrowsException() { // Arrange HtmlHelper htmlHelper = new HtmlHelper(new Mock<ViewContext>().Object, GetViewDataContainer(null), new RouteCollection()); ; // Act & Assert ExceptionHelper.ExpectArgumentExceptionNullOrEmpty( delegate { htmlHelper.HttpMethodOverride(null); }, "httpMethod"); }
public void HttpMethodOverrideGuardClauses() { // Arrange var viewContext = new Mock<ViewContext>().Object; var viewDataContainer = MvcHelper.GetViewDataContainer(null); var htmlHelper = new HtmlHelper(viewContext, viewDataContainer); // Act & Assert ExceptionHelper.ExpectArgumentExceptionNullOrEmpty( () => htmlHelper.HttpMethodOverride(null), "httpMethod" ); ExceptionHelper.ExpectArgumentException( () => htmlHelper.HttpMethodOverride((HttpVerbs)10000), @"The specified HttpVerbs value is not supported. The supported values are Delete, Head, and Put. Parameter name: httpVerb" ); ExceptionHelper.ExpectArgumentException( () => htmlHelper.HttpMethodOverride(HttpVerbs.Get), @"The specified HttpVerbs value is not supported. The supported values are Delete, Head, and Put. Parameter name: httpVerb" ); ExceptionHelper.ExpectArgumentException( () => htmlHelper.HttpMethodOverride(HttpVerbs.Post), @"The specified HttpVerbs value is not supported. The supported values are Delete, Head, and Put. Parameter name: httpVerb" ); ExceptionHelper.ExpectArgumentException( () => htmlHelper.HttpMethodOverride("gEt"), @"The GET and POST HTTP methods are not supported. Parameter name: httpMethod" ); ExceptionHelper.ExpectArgumentException( () => htmlHelper.HttpMethodOverride("pOsT"), @"The GET and POST HTTP methods are not supported. Parameter name: httpMethod" ); }