From 9f360c2b9b3cc3ab239ac5c45300e345f2e4765d Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 19 Jan 2016 12:52:26 +0100 Subject: [PATCH] Fix test broken by PR #1027 --- src/Umbraco.Tests/Mvc/UmbracoViewPageTests.cs | 12 ++++++------ src/Umbraco.Web/Mvc/ModelBindingException.cs | 14 ++++++++++++++ src/Umbraco.Web/Mvc/RenderModelBinder.cs | 6 +++--- src/Umbraco.Web/Umbraco.Web.csproj | 1 + 4 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 src/Umbraco.Web/Mvc/ModelBindingException.cs diff --git a/src/Umbraco.Tests/Mvc/UmbracoViewPageTests.cs b/src/Umbraco.Tests/Mvc/UmbracoViewPageTests.cs index e6c497d1b6..ed6cc9b4eb 100644 --- a/src/Umbraco.Tests/Mvc/UmbracoViewPageTests.cs +++ b/src/Umbraco.Tests/Mvc/UmbracoViewPageTests.cs @@ -90,7 +90,7 @@ namespace Umbraco.Tests.Mvc view.ViewContext = GetViewContext(); - Assert.Throws(() => view.SetViewDataX(viewData)); + Assert.Throws(() => view.SetViewDataX(viewData)); } [Test] @@ -133,7 +133,7 @@ namespace Umbraco.Tests.Mvc view.ViewContext = GetViewContext(); - Assert.Throws(() => view.SetViewDataX(viewData)); + Assert.Throws(() => view.SetViewDataX(viewData)); } #endregion @@ -191,7 +191,7 @@ namespace Umbraco.Tests.Mvc var viewData = new ViewDataDictionary(model); view.ViewContext = GetViewContext(); - Assert.Throws(() => view.SetViewDataX(viewData)); + Assert.Throws(() => view.SetViewDataX(viewData)); } [Test] @@ -233,7 +233,7 @@ namespace Umbraco.Tests.Mvc var viewData = new ViewDataDictionary(model); view.ViewContext = GetViewContext(); - Assert.Throws(() => view.SetViewDataX(viewData)); + Assert.Throws(() => view.SetViewDataX(viewData)); } #endregion @@ -289,7 +289,7 @@ namespace Umbraco.Tests.Mvc var viewData = new ViewDataDictionary(content); view.ViewContext = GetViewContext(); - Assert.Throws(() =>view.SetViewDataX(viewData)); + Assert.Throws(() =>view.SetViewDataX(viewData)); } [Test] @@ -313,7 +313,7 @@ namespace Umbraco.Tests.Mvc var viewData = new ViewDataDictionary(content); view.ViewContext = GetViewContext(); - Assert.Throws(() => view.SetViewDataX(viewData)); + Assert.Throws(() => view.SetViewDataX(viewData)); } [Test] diff --git a/src/Umbraco.Web/Mvc/ModelBindingException.cs b/src/Umbraco.Web/Mvc/ModelBindingException.cs new file mode 100644 index 0000000000..d675ae4a65 --- /dev/null +++ b/src/Umbraco.Web/Mvc/ModelBindingException.cs @@ -0,0 +1,14 @@ +using System; + +namespace Umbraco.Web.Mvc +{ + public class ModelBindingException : Exception + { + public ModelBindingException() + { } + + public ModelBindingException(string message) + : base(message) + { } + } +} diff --git a/src/Umbraco.Web/Mvc/RenderModelBinder.cs b/src/Umbraco.Web/Mvc/RenderModelBinder.cs index 8d9d33c29c..20045604d0 100644 --- a/src/Umbraco.Web/Mvc/RenderModelBinder.cs +++ b/src/Umbraco.Web/Mvc/RenderModelBinder.cs @@ -73,7 +73,7 @@ namespace Umbraco.Web.Mvc if (modelType.Implements()) { if ((sourceContent.GetType().Inherits(modelType)) == false) - throw new Exception(string.Format("Cannot bind source content type {0} to model type {1}.", + throw new ModelBindingException(string.Format("Cannot bind source content type {0} to model type {1}.", sourceContent.GetType(), modelType)); return sourceContent; } @@ -89,7 +89,7 @@ namespace Umbraco.Web.Mvc { var targetContentType = modelType.GetGenericArguments()[0]; if ((sourceContent.GetType().Inherits(targetContentType)) == false) - throw new Exception(string.Format("Cannot bind source content type {0} to model content type {1}.", + throw new ModelBindingException(string.Format("Cannot bind source content type {0} to model content type {1}.", sourceContent.GetType(), targetContentType)); return Activator.CreateInstance(modelType, sourceContent, culture); } @@ -100,7 +100,7 @@ namespace Umbraco.Web.Mvc if (attempt2.Success) return attempt2.Result; // fail - throw new Exception(string.Format("Cannot bind source type {0} to model type {1}.", + throw new ModelBindingException(string.Format("Cannot bind source type {0} to model type {1}.", sourceType, modelType)); } } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 4b6a788296..3d659a36c7 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -316,6 +316,7 @@ +