Permalink
Browse files

Added integration tests to stop from regressing on issues like #268

  • Loading branch information...
1 parent eab2ff2 commit 1ff85c7fe9a62dc26ba82cb6ad0aac8114bed039 @nikmd23 nikmd23 committed Mar 1, 2013
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2010
+# Visual Studio 2012
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{0352975D-08B7-435E-B444-A77292D4F6E1}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
@@ -0,0 +1,21 @@
+using System;
+using System.Web.Mvc;
+using Glimpse.Test.Integration.Site.Models;
+
+namespace Glimpse.Test.Integration.Site.Code
+{
+ public class CustomModelBinder : IModelBinder
+ {
+ public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
+ {
+ var result = bindingContext.ValueProvider.GetValue("id");
+
+ if (result == null)
+ {
+ return null;
+ }
+
+ return new CustomModel(Guid.Parse(result.AttemptedValue));
+ }
+ }
+}
@@ -0,0 +1,17 @@
+using System;
+using System.Web.Mvc;
+using Glimpse.Test.Integration.Site.Models;
+
+namespace Glimpse.Test.Integration.Site.Code
+{
+ public class CustomModelBinderProvider : IModelBinderProvider
+ {
+ public IModelBinder GetBinder(Type modelType)
+ {
+ if (modelType == typeof(CustomModel))
+ return new CustomModelBinder();
+
+ return null;
+ }
+ }
+}
@@ -0,0 +1,23 @@
+using System;
+using System.Web.Mvc;
+using Glimpse.Test.Integration.Site.Models;
+
+namespace Glimpse.Test.Integration.Site.Controllers
+{
+ public class BindingController : Controller
+ {
+ public ActionResult DefaultBinder(Guid id)
+ {
+ HttpContext.Items.Add(IntegrationTestTab.Expected, id.ToString());
+
+ return View(model: id);
+ }
+
+ public ActionResult CustomBinder(CustomModel customModel)
+ {
+ HttpContext.Items.Add(IntegrationTestTab.Expected, customModel.ToString());
+
+ return View(model: customModel);
+ }
+ }
+}
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -17,6 +18,14 @@
<UseIISExpress>false</UseIISExpress>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>4.0</OldToolsVersion>
+ <UpgradeBackupLocation />
+ <IISExpressSSLPort />
+ <IISExpressAnonymousAuthentication />
+ <IISExpressWindowsAuthentication />
+ <IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -40,12 +49,15 @@
<HintPath>..\..\packages\EntityFramework.4.1.10331.0\lib\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Glimpse.AspNet, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Glimpse.AspNet.1.0.0\lib\net40\Glimpse.AspNet.dll</HintPath>
</Reference>
<Reference Include="Glimpse.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Glimpse.1.0.0\lib\net40\Glimpse.Core.dll</HintPath>
</Reference>
<Reference Include="Glimpse.Mvc3, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Glimpse.Mvc3.1.0.0\lib\net40\Glimpse.Mvc3.dll</HintPath>
</Reference>
<Reference Include="System.Data.Entity" />
@@ -75,9 +87,12 @@
<ItemGroup>
<Compile Include="Areas\Area\AreaAreaRegistration.cs" />
<Compile Include="Areas\Area\Controllers\HomeAreaController.cs" />
+ <Compile Include="Code\CustomModelBinder.cs" />
+ <Compile Include="Code\CustomModelBinderProvider.cs" />
<Compile Include="Code\DomainData.cs" />
<Compile Include="Code\DomainRoute.cs" />
<Compile Include="Controllers\AsyncTestController.cs" />
+ <Compile Include="Controllers\BindingController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\RoutingController.cs" />
<Compile Include="Controllers\TraceController.cs" />
@@ -86,6 +101,7 @@
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="IntegrationTestTab.cs" />
+ <Compile Include="Models\CustomModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -118,7 +134,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\Area\Models\" />
- <Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
@@ -150,8 +165,19 @@
<ItemGroup>
<Content Include="Views\AsyncTest\Index.cshtml" />
</ItemGroup>
+ <ItemGroup>
+ <Content Include="Views\Binding\DefaultBinder.cshtml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Views\Binding\CustomBinder.cshtml" />
+ </ItemGroup>
+ <PropertyGroup>
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+ </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
+ <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
@@ -38,6 +38,8 @@ protected void Application_Start()
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
+
+ ModelBinderProviders.BinderProviders.Add(new CustomModelBinderProvider());
}
}
}
@@ -0,0 +1,17 @@
+using System;
+
+namespace Glimpse.Test.Integration.Site.Models
+{
+ public class CustomModel
+ {
+ public CustomModel(Guid guid)
+ {
+ Guid = guid;
+ Timestamp = DateTime.Now;
+ }
+
+ public Guid Guid { get; set; }
+
+ public DateTime Timestamp { get; private set; }
+ }
+}
@@ -0,0 +1,5 @@
+@model Glimpse.Test.Integration.Site.Models.CustomModel
+
+<h2>Binding/CustomBinder</h2>
+
+<p>This is a model binding test page to ensure that Glimpse shows proper IModelBinder binding.</p>
@@ -0,0 +1,5 @@
+@model Guid
+
+<h2>Binding/String</h2>
+
+<p>This is a model binding test page to ensure that Glimpse shows proper URL binding.</p>
Binary file not shown.

0 comments on commit 1ff85c7

Please sign in to comment.