This repository was archived by the owner on Dec 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move setting up options to MvcOptionsSetup
Fixes #760
- Loading branch information
Showing
5 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/Microsoft.AspNet.Mvc.Test/Microsoft.AspNet.Mvc.Test.kproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="__ToolsVersion__" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>5f945b82-fe5f-425c-956c-8bc2f2020254</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="$(OutputType) == 'Console'"> | ||
<DebuggerFlavor>ConsoleDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="$(OutputType) == 'Web'"> | ||
<DebuggerFlavor>WebDebugger</DebuggerFlavor> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'" Label="Configuration"> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'" Label="Configuration"> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Content Include="Project.json" /> | ||
</ItemGroup> | ||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.AspNet.Mvc.ModelBinding; | ||
using Microsoft.AspNet.Mvc.Razor; | ||
using Xunit; | ||
|
||
namespace Microsoft.AspNet.Mvc | ||
{ | ||
public class MvcOptionSetupTest | ||
{ | ||
[Fact] | ||
public void Setup_SetsUpViewEngines() | ||
{ | ||
// Arrange | ||
var mvcOptions = new MvcOptions(); | ||
var setup = new MvcOptionsSetup(); | ||
|
||
// Act | ||
setup.Setup(mvcOptions); | ||
|
||
// Assert | ||
Assert.Equal(1, mvcOptions.ViewEngines.Count); | ||
Assert.Equal(typeof(RazorViewEngine), mvcOptions.ViewEngines[0].ViewEngineType); | ||
} | ||
|
||
[Fact] | ||
public void Setup_SetsUpModelBinders() | ||
{ | ||
// Arrange | ||
var mvcOptions = new MvcOptions(); | ||
var setup = new MvcOptionsSetup(); | ||
|
||
// Act | ||
setup.Setup(mvcOptions); | ||
|
||
// Assert | ||
Assert.Equal(5, mvcOptions.ModelBinders.Count); | ||
Assert.Equal(typeof(TypeConverterModelBinder), mvcOptions.ModelBinders[0].ModelBinderType); | ||
Assert.Equal(typeof(TypeMatchModelBinder), mvcOptions.ModelBinders[1].ModelBinderType); | ||
Assert.Equal(typeof(GenericModelBinder), mvcOptions.ModelBinders[2].ModelBinderType); | ||
Assert.Equal(typeof(MutableObjectModelBinder), mvcOptions.ModelBinders[3].ModelBinderType); | ||
Assert.Equal(typeof(ComplexModelDtoModelBinder), mvcOptions.ModelBinders[4].ModelBinderType); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilationOptions": { | ||
"warningsAsErrors": true | ||
}, | ||
"dependencies": { | ||
"Microsoft.AspNet.Mvc" : "", | ||
"Moq": "4.2.1312.1622", | ||
"Xunit.KRunner": "1.0.0-*" | ||
}, | ||
"commands": { | ||
"test": "Xunit.KRunner" | ||
}, | ||
"configurations": { | ||
"net45": { } | ||
} | ||
} |