diff --git a/Samples/TestStack.FluentMVCTesting.Sample.Tests/TestStack.FluentMVCTesting.Sample.Tests.csproj b/Samples/TestStack.FluentMVCTesting.Sample.Tests/TestStack.FluentMVCTesting.Sample.Tests.csproj index 3f1a983..858864c 100644 --- a/Samples/TestStack.FluentMVCTesting.Sample.Tests/TestStack.FluentMVCTesting.Sample.Tests.csproj +++ b/Samples/TestStack.FluentMVCTesting.Sample.Tests/TestStack.FluentMVCTesting.Sample.Tests.csproj @@ -49,29 +49,29 @@ - - ..\..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll - True + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll - - ..\..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll - True + + False + ..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll - - ..\..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll - True + + False + ..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll - - ..\..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll - True + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll - - ..\..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll - True + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll - - ..\..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll - True + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll diff --git a/Samples/TestStack.FluentMVCTesting.Sample.Tests/packages.config b/Samples/TestStack.FluentMVCTesting.Sample.Tests/packages.config index 9757012..756879d 100644 --- a/Samples/TestStack.FluentMVCTesting.Sample.Tests/packages.config +++ b/Samples/TestStack.FluentMVCTesting.Sample.Tests/packages.config @@ -1,8 +1,8 @@  - - - + + + diff --git a/Samples/TestStack.FluentMVCTesting.Sample/TestStack.FluentMVCTesting.Sample.csproj b/Samples/TestStack.FluentMVCTesting.Sample/TestStack.FluentMVCTesting.Sample.csproj index 525a4b7..9d208d7 100644 --- a/Samples/TestStack.FluentMVCTesting.Sample/TestStack.FluentMVCTesting.Sample.csproj +++ b/Samples/TestStack.FluentMVCTesting.Sample/TestStack.FluentMVCTesting.Sample.csproj @@ -53,29 +53,29 @@ - - ..\..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll - True + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll - - ..\..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll - True + + False + ..\..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll - - ..\..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll - True + + False + ..\..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll - - ..\..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll - True + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll - - ..\..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll - True + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll - - ..\..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll - True + + False + ..\..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll diff --git a/Samples/TestStack.FluentMVCTesting.Sample/Web.config b/Samples/TestStack.FluentMVCTesting.Sample/Web.config index 5766172..73d58b9 100644 --- a/Samples/TestStack.FluentMVCTesting.Sample/Web.config +++ b/Samples/TestStack.FluentMVCTesting.Sample/Web.config @@ -47,7 +47,7 @@ - + diff --git a/Samples/TestStack.FluentMVCTesting.Sample/packages.config b/Samples/TestStack.FluentMVCTesting.Sample/packages.config index 96d2cec..df7e914 100644 --- a/Samples/TestStack.FluentMVCTesting.Sample/packages.config +++ b/Samples/TestStack.FluentMVCTesting.Sample/packages.config @@ -8,10 +8,10 @@ - - + + - + diff --git a/Settings.StyleCop b/Settings.StyleCop new file mode 100644 index 0000000..b8dcb05 --- /dev/null +++ b/Settings.StyleCop @@ -0,0 +1,5 @@ + + + False + + \ No newline at end of file diff --git a/TestStack.FluentMVCTesting.Tests/MvcPipeline/WithMvcPipelineShould.cs b/TestStack.FluentMVCTesting.Tests/MvcPipeline/WithMvcPipelineShould.cs new file mode 100644 index 0000000..025f354 --- /dev/null +++ b/TestStack.FluentMVCTesting.Tests/MvcPipeline/WithMvcPipelineShould.cs @@ -0,0 +1,53 @@ +using System.Web.Mvc; +using NUnit.Framework; +using TestStack.FluentMVCTesting.Tests.TestControllers; + +namespace TestStack.FluentMVCTesting.Tests.MvcPipeline +{ +#if NET45 + [TestFixture] + class WithMvcPipelineShould + { + [Test] + public void Call_action() + { + var controller = new ControllerExtensionsController(); + controller.WithMvcPipelineTo(c => c.SomeAction()); + Assert.That(controller.SomeActionCalled); + } + + [Test] + public void Can_exercise_filters() + { + GlobalFilters.Filters.Add(new LoggingFilter()); + var controller = new ControllerExtensionsController(); + + controller.WithMvcPipelineTo(c => c.SomeAction()); + + Assert.That(LoggingFilter.OnActionExecutingRan); + Assert.That(LoggingFilter.OnActionExecutedRan); + } + + private class LoggingFilter : ActionFilterAttribute, IActionFilter + { + public static bool OnActionExecutingRan; + public static bool OnActionExecutedRan; + + public LoggingFilter() + { + OnActionExecutingRan = false; + OnActionExecutedRan = false; + } + public override void OnActionExecuting(ActionExecutingContext filterContext) + { + OnActionExecutingRan = true; + } + + public override void OnActionExecuted(ActionExecutedContext filterContext) + { + OnActionExecutedRan = true; + } + } + } +#endif +} diff --git a/TestStack.FluentMVCTesting.Tests/TestStack.FluentMVCTesting.Tests.csproj b/TestStack.FluentMVCTesting.Tests/TestStack.FluentMVCTesting.Tests.csproj index 5129022..53f307d 100644 --- a/TestStack.FluentMVCTesting.Tests/TestStack.FluentMVCTesting.Tests.csproj +++ b/TestStack.FluentMVCTesting.Tests/TestStack.FluentMVCTesting.Tests.csproj @@ -20,7 +20,7 @@ full false bin\Debug\ - DEBUG;TRACE + TRACE;DEBUG;NET45 prompt 4 false @@ -50,29 +50,29 @@ - - ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll - True + + False + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll - - ..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll - True + + False + ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll - - ..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll - True + + False + ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll - - ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll - True + + False + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll - - ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll - True + + False + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll - - ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll - True + + False + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll @@ -89,6 +89,7 @@ + @@ -108,6 +109,7 @@ + diff --git a/TestStack.FluentMVCTesting.Tests/app.config b/TestStack.FluentMVCTesting.Tests/app.config new file mode 100644 index 0000000..d7256aa --- /dev/null +++ b/TestStack.FluentMVCTesting.Tests/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/TestStack.FluentMVCTesting.Tests/packages.config b/TestStack.FluentMVCTesting.Tests/packages.config index 9757012..756879d 100644 --- a/TestStack.FluentMVCTesting.Tests/packages.config +++ b/TestStack.FluentMVCTesting.Tests/packages.config @@ -1,8 +1,8 @@  - - - + + + diff --git a/TestStack.FluentMVCTesting.sln b/TestStack.FluentMVCTesting.sln index e772e1f..9f158f0 100644 --- a/TestStack.FluentMVCTesting.sln +++ b/TestStack.FluentMVCTesting.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30501.0 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestStack.FluentMVCTesting", "TestStack.FluentMVCTesting\TestStack.FluentMVCTesting.csproj", "{152CA00F-18D3-4CF5-8CA0-2C5B70CBEA19}" EndProject @@ -30,6 +30,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestStack.FluentMVCTesting. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestStack.FluentMVCTesting.Sample", "Samples\TestStack.FluentMVCTesting.Sample\TestStack.FluentMVCTesting.Sample.csproj", "{FD292B9E-1493-428F-8AF6-F7CF9CF463C5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xania.AspNet.Simulator", "Xania.AspNet.Simulator\Xania.AspNet.Simulator.csproj", "{04B8C6C8-D531-468D-B07B-C2EBF9BF13E8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -68,6 +70,10 @@ Global {FD292B9E-1493-428F-8AF6-F7CF9CF463C5}.Debug|Any CPU.Build.0 = Debug|Any CPU {FD292B9E-1493-428F-8AF6-F7CF9CF463C5}.Release|Any CPU.ActiveCfg = Release|Any CPU {FD292B9E-1493-428F-8AF6-F7CF9CF463C5}.Release|Any CPU.Build.0 = Release|Any CPU + {04B8C6C8-D531-468D-B07B-C2EBF9BF13E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {04B8C6C8-D531-468D-B07B-C2EBF9BF13E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {04B8C6C8-D531-468D-B07B-C2EBF9BF13E8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {04B8C6C8-D531-468D-B07B-C2EBF9BF13E8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TestStack.FluentMvcTesting/ControllerExtensions.cs b/TestStack.FluentMvcTesting/ControllerExtensions.cs index 4c377c8..bdf4aeb 100644 --- a/TestStack.FluentMvcTesting/ControllerExtensions.cs +++ b/TestStack.FluentMvcTesting/ControllerExtensions.cs @@ -3,19 +3,21 @@ using System.Threading.Tasks; using System.Web.Mvc; +#if NET45 +using Xania.AspNet.Simulator; +#endif + namespace TestStack.FluentMVCTesting { public static class ControllerExtensions { - public static T WithModelErrors(this T controller) where T : Controller { controller.ModelState.AddModelError("Key", "Value"); return controller; } - public static ControllerResultTest WithCallTo(this T controller, Expression> actionCall) - where T : Controller + public static ControllerResultTest WithCallTo(this T controller, Expression> actionCall) where T : Controller where TAction : ActionResult { var actionName = ((MethodCallExpression)actionCall.Body).Method.Name; @@ -36,6 +38,30 @@ public static ControllerResultTest WithCallTo(this T controller, return new ControllerResultTest(controller, actionName, actionResult); } +#if NET45 + public static ControllerResultTest WithMvcPipelineTo(this T controller, Expression> actionCall) + where T : Controller + where TAction : ActionResult + { + var expression = Expression.Lambda>(actionCall.Body, actionCall.Parameters); + var action = controller.Action(expression); + var result = action.Execute(); + + return new ControllerResultTest(controller, action.ActionDescriptor.ActionName, result.ActionResult); + } + + public static ControllerResultTest WithMvcPipelineTo(this T controller, Expression>> actionCall) + where T : Controller + where TAction : ActionResult + { + var expression = Expression.Lambda>(actionCall.Body, actionCall.Parameters); + var action = controller.Action(expression); + var result = action.Execute(); + + return new ControllerResultTest(controller, action.ActionDescriptor.ActionName, result.ActionResult); + } +#endif + public static ControllerResultTest WithCallToChild(this T controller, Expression> actionCall) where T : Controller where TAction : ActionResult diff --git a/TestStack.FluentMvcTesting/TestStack.FluentMVCTesting.csproj b/TestStack.FluentMvcTesting/TestStack.FluentMVCTesting.csproj index b9925ec..69d81ed 100644 --- a/TestStack.FluentMvcTesting/TestStack.FluentMVCTesting.csproj +++ b/TestStack.FluentMvcTesting/TestStack.FluentMVCTesting.csproj @@ -20,7 +20,7 @@ full false bin\Debug\ - DEBUG;TRACE + TRACE;DEBUG;NET45 prompt 4 false @@ -45,29 +45,29 @@ - - ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll - True + + False + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll - - ..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll - True + + False + ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll - - ..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll - True + + False + ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll - - ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll - True + + False + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll - - ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll - True + + False + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll - - ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll - True + + False + ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll @@ -95,12 +95,19 @@ + + + + {04b8c6c8-d531-468d-b07b-c2ebf9bf13e8} + Xania.AspNet.Simulator + + + \ No newline at end of file diff --git a/Xania.AspNet.Simulator/app.config b/Xania.AspNet.Simulator/app.config new file mode 100644 index 0000000..e2e0187 --- /dev/null +++ b/Xania.AspNet.Simulator/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Xania.AspNet.Simulator/packages.config b/Xania.AspNet.Simulator/packages.config new file mode 100644 index 0000000..60d6113 --- /dev/null +++ b/Xania.AspNet.Simulator/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file