diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpCreateViewTemplateTests.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpCreateViewTemplateTests.cs index 7851f876f5..98ac659253 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpCreateViewTemplateTests.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpCreateViewTemplateTests.cs @@ -226,6 +226,54 @@ MyView
<%: Html.ActionLink(""Back"", ""Index"") %>
+"; + Assert.AreEqual(expectedOutput, output); + } + + [Test] + public void TransformText_ModelHasTwoPropertiesAndIsPartialView_ReturnsControlWithFormAndHtmlEditorForModelProperties() + { + CreateViewTemplatePreprocessor(); + mvcHost.IsPartialView = true; + Type modelType = typeof(ModelWithTwoProperties); + mvcHost.ViewDataType = modelType; + mvcHost.ViewDataTypeName = modelType.FullName; + mvcHost.ViewName = "MyView"; + + string output = templatePreprocessor.TransformText(); + + string expectedOutput = +@"<%@ Control Language=""C#"" Inherits=""System.Web.Mvc.ViewUserControl"" %> + +<% using (Html.BeginForm()) { %> + <%: Html.ValidationSummary(true) %> +
+ ModelWithTwoProperties + +
+ <%: Html.LabelFor(model => model.FirstName) %> +
+
+ <%: Html.EditorFor(model => model.FirstName) %> + <%: Html.ValidationMessageFor(model => model.FirstName) %> +
+ +
+ <%: Html.LabelFor(model => model.LastName) %> +
+
+ <%: Html.EditorFor(model => model.LastName) %> + <%: Html.ValidationMessageFor(model => model.LastName) %> +
+ +

+ +

+
+<% } %> +
+ <%: Html.ActionLink(""Back"", ""Index"") %> +
"; Assert.AreEqual(expectedOutput, output); } diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpDeleteViewTemplateTests.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpDeleteViewTemplateTests.cs index da4869733d..415790e51f 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpDeleteViewTemplateTests.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpDeleteViewTemplateTests.cs @@ -209,6 +209,48 @@ MyView <%: Html.ActionLink(""Back"", ""Index"") %>

<% } %> +"; + Assert.AreEqual(expectedOutput, output); + } + + [Test] + public void TransformText_ModelHasTwoPropertiesAndIsPartialView_ReturnsControlWithHtmlHelpersForModelProperties() + { + CreateViewTemplatePreprocessor(); + mvcHost.IsPartialView = true; + Type modelType = typeof(ModelWithTwoProperties); + mvcHost.ViewDataType = modelType; + mvcHost.ViewDataTypeName = modelType.FullName; + mvcHost.ViewName = "MyView"; + + string output = templatePreprocessor.TransformText(); + + string expectedOutput = +@"<%@ Control Language=""C#"" Inherits=""System.Web.Mvc.ViewUserControl"" %> + +
+ ModelWithTwoProperties + +
+ <%: Html.LabelFor(model => model.FirstName) %> +
+
+ <%: Html.DisplayFor(model => model.FirstName) %> +
+ +
+ <%: Html.LabelFor(model => model.LastName) %> +
+
+ <%: Html.DisplayFor(model => model.LastName) %> +
+
+<% using (Html.BeginForm()) { %> +

+ | + <%: Html.ActionLink(""Back"", ""Index"") %> +

+<% } %> "; Assert.AreEqual(expectedOutput, output); } diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpDetailsViewTemplateTests.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpDetailsViewTemplateTests.cs index 0916ba0abb..fc231ba42c 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpDetailsViewTemplateTests.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpDetailsViewTemplateTests.cs @@ -201,6 +201,46 @@ MyView <%: Html.ActionLink(""Edit"", ""Edit"") %> | <%: Html.ActionLink(""Back"", ""Index"") %>

+"; + Assert.AreEqual(expectedOutput, output); + } + + [Test] + public void TransformText_ModelHasTwoPropertiesAndIsPartialView_ReturnsControlWithFormAndHtmlHelpersForModelProperty() + { + CreateViewTemplatePreprocessor(); + mvcHost.IsPartialView = true; + Type modelType = typeof(ModelWithTwoProperties); + mvcHost.ViewDataType = modelType; + mvcHost.ViewDataTypeName = modelType.FullName; + mvcHost.ViewName = "MyView"; + + string output = templatePreprocessor.TransformText(); + + string expectedOutput = +@"<%@ Control Language=""C#"" Inherits=""System.Web.Mvc.ViewUserControl"" %> + +
+ ModelWithTwoProperties + +
+ <%: Html.LabelFor(model => model.FirstName) %> +
+
+ <%: Html.DisplayFor(model => model.FirstName) %> +
+ +
+ <%: Html.LabelFor(model => model.LastName) %> +
+
+ <%: Html.DisplayFor(model => model.LastName) %> +
+
+

+ <%: Html.ActionLink(""Edit"", ""Edit"") %> | + <%: Html.ActionLink(""Back"", ""Index"") %> +

"; Assert.AreEqual(expectedOutput, output); } diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpEditViewTemplateTests.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpEditViewTemplateTests.cs index 5756217fba..7eeb1be248 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpEditViewTemplateTests.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/AspxCSharpEditViewTemplateTests.cs @@ -226,6 +226,54 @@ MyView
<%: Html.ActionLink(""Back"", ""Index"") %>
+"; + Assert.AreEqual(expectedOutput, output); + } + + [Test] + public void TransformText_ModelHasTwoPropertiesAndIsPartialView_ReturnsControlWithFormAndHtmlHelpersForModelProperties() + { + CreateViewTemplatePreprocessor(); + mvcHost.IsPartialView = true; + Type modelType = typeof(ModelWithTwoProperties); + mvcHost.ViewDataType = modelType; + mvcHost.ViewDataTypeName = modelType.FullName; + mvcHost.ViewName = "MyView"; + + string output = templatePreprocessor.TransformText(); + + string expectedOutput = +@"<%@ Control Language=""C#"" Inherits=""System.Web.Mvc.ViewUserControl"" %> + +<% using (Html.BeginForm()) { %> + <%: Html.ValidationSummary(true) %> +
+ ModelWithTwoProperties + +
+ <%: Html.LabelFor(model => model.FirstName) %> +
+
+ <%: Html.EditorFor(model => model.FirstName) %> + <%: Html.ValidationMessageFor(model => model.FirstName) %> +
+ +
+ <%: Html.LabelFor(model => model.LastName) %> +
+
+ <%: Html.EditorFor(model => model.LastName) %> + <%: Html.ValidationMessageFor(model => model.LastName) %> +
+ +

+ +

+
+<% } %> +
+ <%: Html.ActionLink(""Back"", ""Index"") %> +
"; Assert.AreEqual(expectedOutput, output); } diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpCreateViewTemplateTests.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpCreateViewTemplateTests.cs index 25ad7977c7..22c6b55962 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpCreateViewTemplateTests.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpCreateViewTemplateTests.cs @@ -227,6 +227,54 @@ namespace AspNet.Mvc.Tests.CodeTemplates
@Html.ActionLink(""Back"", ""Index"")
+"; + Assert.AreEqual(expectedOutput, output); + } + + [Test] + public void TransformText_ModelHasTwoPropertiesAndIsPartialView_ReturnsControlWithHtmlEditorsForModelProperties() + { + CreateViewTemplatePreprocessor(); + mvcHost.IsPartialView = true; + Type modelType = typeof(ModelWithTwoProperties); + mvcHost.ViewDataType = modelType; + mvcHost.ViewDataTypeName = modelType.FullName; + mvcHost.ViewName = "MyView"; + + string output = templatePreprocessor.TransformText(); + + string expectedOutput = +@"@model AspNet.Mvc.Tests.CodeTemplates.Models.ModelWithTwoProperties + +@using (Html.BeginForm()) { + @Html.ValidationSummary(true) +
+ ModelWithTwoProperties + +
+ @Html.LabelFor(model => model.FirstName) +
+
+ @Html.EditorFor(model => model.FirstName) + @Html.ValidationMessageFor(model => model.FirstName) +
+ +
+ @Html.LabelFor(model => model.LastName) +
+
+ @Html.EditorFor(model => model.LastName) + @Html.ValidationMessageFor(model => model.LastName) +
+ +

+ +

+
+} +
+ @Html.ActionLink(""Back"", ""Index"") +
"; Assert.AreEqual(expectedOutput, output); } diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpDeleteViewTemplateTests.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpDeleteViewTemplateTests.cs index 8834ffda21..b0744ca953 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpDeleteViewTemplateTests.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpDeleteViewTemplateTests.cs @@ -210,6 +210,48 @@ namespace AspNet.Mvc.Tests.CodeTemplates @Html.ActionLink(""Back"", ""Index"")

} +"; + Assert.AreEqual(expectedOutput, output); + } + + [Test] + public void TransformText_ModelHasTwoPropertiesAndIsPartialView_ReturnsControlWithHtmlHelpersForModelProperties() + { + CreateViewTemplatePreprocessor(); + mvcHost.IsPartialView = true; + Type modelType = typeof(ModelWithTwoProperties); + mvcHost.ViewDataType = modelType; + mvcHost.ViewDataTypeName = modelType.FullName; + mvcHost.ViewName = "MyView"; + + string output = templatePreprocessor.TransformText(); + + string expectedOutput = +@"@model AspNet.Mvc.Tests.CodeTemplates.Models.ModelWithTwoProperties + +
+ ModelWithTwoProperties + +
+ @Html.LabelFor(model => model.FirstName) +
+
+ @Html.DisplayFor(model => model.FirstName) +
+ +
+ @Html.LabelFor(model => model.LastName) +
+
+ @Html.DisplayFor(model => model.LastName) +
+
+@using (Html.BeginForm()) { +

+ | + @Html.ActionLink(""Back"", ""Index"") +

+} "; Assert.AreEqual(expectedOutput, output); } diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpDetailsViewTemplateTests.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpDetailsViewTemplateTests.cs index 999354d7f4..14ef572034 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpDetailsViewTemplateTests.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpDetailsViewTemplateTests.cs @@ -202,6 +202,45 @@ namespace AspNet.Mvc.Tests.CodeTemplates @Html.ActionLink(""Edit"", ""Edit"") | @Html.ActionLink(""Back"", ""Index"")

+"; + Assert.AreEqual(expectedOutput, output); + } + [Test] + public void TransformText_ModelHasTwoPropertiesAndIsPartialView_ReturnsControlWithHtmlHelperForModelProperties() + { + CreateViewTemplatePreprocessor(); + mvcHost.IsPartialView = true; + Type modelType = typeof(ModelWithTwoProperties); + mvcHost.ViewDataType = modelType; + mvcHost.ViewDataTypeName = modelType.FullName; + mvcHost.ViewName = "MyView"; + + string output = templatePreprocessor.TransformText(); + + string expectedOutput = +@"@model AspNet.Mvc.Tests.CodeTemplates.Models.ModelWithTwoProperties + +
+ ModelWithTwoProperties + +
+ @Html.LabelFor(model => model.FirstName) +
+
+ @Html.DisplayFor(model => model.FirstName) +
+ +
+ @Html.LabelFor(model => model.LastName) +
+
+ @Html.DisplayFor(model => model.LastName) +
+
+

+ @Html.ActionLink(""Edit"", ""Edit"") | + @Html.ActionLink(""Back"", ""Index"") +

"; Assert.AreEqual(expectedOutput, output); } diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpEditViewTemplateTests.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpEditViewTemplateTests.cs index adc7d84acb..dc26a37d8b 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpEditViewTemplateTests.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpEditViewTemplateTests.cs @@ -227,6 +227,54 @@ namespace AspNet.Mvc.Tests.CodeTemplates
@Html.ActionLink(""Back"", ""Index"")
+"; + Assert.AreEqual(expectedOutput, output); + } + + [Test] + public void TransformText_ModelHasTwoPropertiesAndIsPartialView_ReturnsControlWithHtmlHelpersForModelProperties() + { + CreateViewTemplatePreprocessor(); + mvcHost.IsPartialView = true; + Type modelType = typeof(ModelWithTwoProperties); + mvcHost.ViewDataType = modelType; + mvcHost.ViewDataTypeName = modelType.FullName; + mvcHost.ViewName = "MyView"; + + string output = templatePreprocessor.TransformText(); + + string expectedOutput = +@"@model AspNet.Mvc.Tests.CodeTemplates.Models.ModelWithTwoProperties + +@using (Html.BeginForm()) { + @Html.ValidationSummary(true) +
+ ModelWithTwoProperties + +
+ @Html.LabelFor(model => model.FirstName) +
+
+ @Html.EditorFor(model => model.FirstName) + @Html.ValidationMessageFor(model => model.FirstName) +
+ +
+ @Html.LabelFor(model => model.LastName) +
+
+ @Html.EditorFor(model => model.LastName) + @Html.ValidationMessageFor(model => model.LastName) +
+ +

+ +

+
+} +
+ @Html.ActionLink(""Back"", ""Index"") +
"; Assert.AreEqual(expectedOutput, output); }