Add TestCommon project
This commit is contained in:
parent
3d247ec028
commit
fc00aff7c5
|
|
@ -58,6 +58,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.PageExecut
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Common.Test", "test\Microsoft.AspNet.Mvc.Common.Test\Microsoft.AspNet.Mvc.Common.Test.xproj", "{0449D6D2-BE1B-4E29-8E1B-444420802C03}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestCommon", "test\Microsoft.AspNet.Mvc.TestCommon\Microsoft.AspNet.Mvc.TestCommon.xproj", "{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -304,6 +306,18 @@ Global
|
|||
{0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{0449D6D2-BE1B-4E29-8E1B-444420802C03}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -331,5 +345,6 @@ Global
|
|||
{22019146-BDFA-442E-8C8E-345FB9644578} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{4DA2D7C1-A7B6-4C01-B57D-89E6EA4609DE} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{0449D6D2-BE1B-4E29-8E1B-444420802C03} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
15
Mvc.sln
15
Mvc.sln
|
|
@ -150,6 +150,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LowercaseUrlsWebSite", "tes
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TempDataWebSite", "test\WebSites\TempDataWebSite\TempDataWebSite.xproj", "{8AEB631E-AB74-4D2E-83FB-8931EE10D9D3}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestCommon", "test\Microsoft.AspNet.Mvc.TestCommon\Microsoft.AspNet.Mvc.TestCommon.xproj", "{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -880,6 +882,18 @@ Global
|
|||
{8AEB631E-AB74-4D2E-83FB-8931EE10D9D3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{8AEB631E-AB74-4D2E-83FB-8931EE10D9D3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{8AEB631E-AB74-4D2E-83FB-8931EE10D9D3}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -953,5 +967,6 @@ Global
|
|||
{B11C99C9-E577-4CA2-AC53-4F20EA71AD34} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{BCDB13A6-7D6E-485E-8424-A156432B71AC} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{8AEB631E-AB74-4D2E-83FB-8931EE10D9D3} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{F504357E-C2E1-4818-BA5C-9A2EAC25FEE5} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -1,183 +0,0 @@
|
|||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding.Metadata;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||
{
|
||||
public class TestModelMetadataProvider : DefaultModelMetadataProvider
|
||||
{
|
||||
// Creates a provider with all the defaults - includes data annotations
|
||||
public static IModelMetadataProvider CreateDefaultProvider()
|
||||
{
|
||||
var detailsProviders = new IMetadataDetailsProvider[]
|
||||
{
|
||||
new DefaultBindingMetadataProvider(),
|
||||
new DataAnnotationsMetadataDetailsProvider(),
|
||||
};
|
||||
|
||||
var compositeDetailsProvider = new DefaultCompositeMetadataDetailsProvider(detailsProviders);
|
||||
return new DefaultModelMetadataProvider(compositeDetailsProvider);
|
||||
}
|
||||
|
||||
private readonly TestModelMetadataDetailsProvider _detailsProvider;
|
||||
|
||||
public TestModelMetadataProvider()
|
||||
: this(new TestModelMetadataDetailsProvider())
|
||||
{
|
||||
}
|
||||
|
||||
private TestModelMetadataProvider(TestModelMetadataDetailsProvider detailsProvider)
|
||||
: base(new DefaultCompositeMetadataDetailsProvider(new IMetadataDetailsProvider[]
|
||||
{
|
||||
new DefaultBindingMetadataProvider(),
|
||||
new DataAnnotationsMetadataDetailsProvider(),
|
||||
detailsProvider
|
||||
}))
|
||||
{
|
||||
_detailsProvider = detailsProvider;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForType(Type type)
|
||||
{
|
||||
var key = ModelMetadataIdentity.ForType(type);
|
||||
|
||||
var builder = new MetadataBuilder(key);
|
||||
_detailsProvider.Builders.Add(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForType<TModel>()
|
||||
{
|
||||
return ForType(typeof(TModel));
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForProperty(Type containerType, string propertyName)
|
||||
{
|
||||
var property = containerType.GetRuntimeProperty(propertyName);
|
||||
Assert.NotNull(property);
|
||||
|
||||
var key = ModelMetadataIdentity.ForProperty(property.PropertyType, property.Name, containerType);
|
||||
|
||||
var builder = new MetadataBuilder(key);
|
||||
_detailsProvider.Builders.Add(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForProperty<TContainer>(string propertyName)
|
||||
{
|
||||
return ForProperty(typeof(TContainer), propertyName);
|
||||
}
|
||||
|
||||
private class TestModelMetadataDetailsProvider :
|
||||
IBindingMetadataProvider,
|
||||
IDisplayMetadataProvider,
|
||||
IValidationMetadataProvider
|
||||
{
|
||||
public List<MetadataBuilder> Builders { get; } = new List<MetadataBuilder>();
|
||||
|
||||
public void GetBindingMetadata([NotNull] BindingMetadataProviderContext context)
|
||||
{
|
||||
foreach (var builder in Builders)
|
||||
{
|
||||
builder.Apply(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetDisplayMetadata([NotNull] DisplayMetadataProviderContext context)
|
||||
{
|
||||
foreach (var builder in Builders)
|
||||
{
|
||||
builder.Apply(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetValidationMetadata([NotNull] ValidationMetadataProviderContext context)
|
||||
{
|
||||
foreach (var builder in Builders)
|
||||
{
|
||||
builder.Apply(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMetadataBuilder
|
||||
{
|
||||
IMetadataBuilder BindingDetails(Action<BindingMetadata> action);
|
||||
|
||||
IMetadataBuilder DisplayDetails(Action<DisplayMetadata> action);
|
||||
|
||||
IMetadataBuilder ValidationDetails(Action<ValidationMetadata> action);
|
||||
}
|
||||
|
||||
private class MetadataBuilder : IMetadataBuilder
|
||||
{
|
||||
private List<Action<BindingMetadata>> _bindingActions = new List<Action<BindingMetadata>>();
|
||||
private List<Action<DisplayMetadata>> _displayActions = new List<Action<DisplayMetadata>>();
|
||||
private List<Action<ValidationMetadata>> _valiationActions = new List<Action<ValidationMetadata>>();
|
||||
|
||||
private readonly ModelMetadataIdentity _key;
|
||||
|
||||
public MetadataBuilder(ModelMetadataIdentity key)
|
||||
{
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public void Apply(BindingMetadataProviderContext context)
|
||||
{
|
||||
if (_key.Equals(context.Key))
|
||||
{
|
||||
foreach (var action in _bindingActions)
|
||||
{
|
||||
action(context.BindingMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Apply(DisplayMetadataProviderContext context)
|
||||
{
|
||||
if (_key.Equals(context.Key))
|
||||
{
|
||||
foreach (var action in _displayActions)
|
||||
{
|
||||
action(context.DisplayMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Apply(ValidationMetadataProviderContext context)
|
||||
{
|
||||
if (_key.Equals(context.Key))
|
||||
{
|
||||
foreach (var action in _valiationActions)
|
||||
{
|
||||
action(context.ValidationMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IMetadataBuilder BindingDetails(Action<BindingMetadata> action)
|
||||
{
|
||||
_bindingActions.Add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IMetadataBuilder DisplayDetails(Action<DisplayMetadata> action)
|
||||
{
|
||||
_displayActions.Add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ValidationDetails(Action<ValidationMetadata> action)
|
||||
{
|
||||
_valiationActions.Add(action);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Mvc" : "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.Xml" : "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
|
||||
"Microsoft.AspNet.Mvc.Xml": "6.0.0-*",
|
||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||
"Moq": "4.2.1312.1622",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
|
|
|
|||
|
|
@ -1,183 +0,0 @@
|
|||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding.Metadata;
|
||||
using Microsoft.Framework.Internal;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||
{
|
||||
public class TestModelMetadataProvider : DefaultModelMetadataProvider
|
||||
{
|
||||
// Creates a provider with all the defaults - includes data annotations
|
||||
public static IModelMetadataProvider CreateDefaultProvider()
|
||||
{
|
||||
var detailsProviders = new IMetadataDetailsProvider[]
|
||||
{
|
||||
new DefaultBindingMetadataProvider(),
|
||||
new DataAnnotationsMetadataDetailsProvider(),
|
||||
};
|
||||
|
||||
var compositeDetailsProvider = new DefaultCompositeMetadataDetailsProvider(detailsProviders);
|
||||
return new DefaultModelMetadataProvider(compositeDetailsProvider);
|
||||
}
|
||||
|
||||
private readonly TestModelMetadataDetailsProvider _detailsProvider;
|
||||
|
||||
public TestModelMetadataProvider()
|
||||
: this(new TestModelMetadataDetailsProvider())
|
||||
{
|
||||
}
|
||||
|
||||
private TestModelMetadataProvider(TestModelMetadataDetailsProvider detailsProvider)
|
||||
: base(new DefaultCompositeMetadataDetailsProvider(new IMetadataDetailsProvider[]
|
||||
{
|
||||
new DefaultBindingMetadataProvider(),
|
||||
new DataAnnotationsMetadataDetailsProvider(),
|
||||
detailsProvider
|
||||
}))
|
||||
{
|
||||
_detailsProvider = detailsProvider;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForType(Type type)
|
||||
{
|
||||
var key = ModelMetadataIdentity.ForType(type);
|
||||
|
||||
var builder = new MetadataBuilder(key);
|
||||
_detailsProvider.Builders.Add(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForType<TModel>()
|
||||
{
|
||||
return ForType(typeof(TModel));
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForProperty(Type containerType, string propertyName)
|
||||
{
|
||||
var property = containerType.GetRuntimeProperty(propertyName);
|
||||
Assert.NotNull(property);
|
||||
|
||||
var key = ModelMetadataIdentity.ForProperty(property.PropertyType, property.Name, containerType);
|
||||
|
||||
var builder = new MetadataBuilder(key);
|
||||
_detailsProvider.Builders.Add(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForProperty<TContainer>(string propertyName)
|
||||
{
|
||||
return ForProperty(typeof(TContainer), propertyName);
|
||||
}
|
||||
|
||||
private class TestModelMetadataDetailsProvider :
|
||||
IBindingMetadataProvider,
|
||||
IDisplayMetadataProvider,
|
||||
IValidationMetadataProvider
|
||||
{
|
||||
public List<MetadataBuilder> Builders { get; } = new List<MetadataBuilder>();
|
||||
|
||||
public void GetBindingMetadata([NotNull] BindingMetadataProviderContext context)
|
||||
{
|
||||
foreach (var builder in Builders)
|
||||
{
|
||||
builder.Apply(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetDisplayMetadata([NotNull] DisplayMetadataProviderContext context)
|
||||
{
|
||||
foreach (var builder in Builders)
|
||||
{
|
||||
builder.Apply(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetValidationMetadata([NotNull] ValidationMetadataProviderContext context)
|
||||
{
|
||||
foreach (var builder in Builders)
|
||||
{
|
||||
builder.Apply(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMetadataBuilder
|
||||
{
|
||||
IMetadataBuilder BindingDetails(Action<BindingMetadata> action);
|
||||
|
||||
IMetadataBuilder DisplayDetails(Action<DisplayMetadata> action);
|
||||
|
||||
IMetadataBuilder ValidationDetails(Action<ValidationMetadata> action);
|
||||
}
|
||||
|
||||
private class MetadataBuilder : IMetadataBuilder
|
||||
{
|
||||
private List<Action<BindingMetadata>> _bindingActions = new List<Action<BindingMetadata>>();
|
||||
private List<Action<DisplayMetadata>> _displayActions = new List<Action<DisplayMetadata>>();
|
||||
private List<Action<ValidationMetadata>> _valiationActions = new List<Action<ValidationMetadata>>();
|
||||
|
||||
private readonly ModelMetadataIdentity _key;
|
||||
|
||||
public MetadataBuilder(ModelMetadataIdentity key)
|
||||
{
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public void Apply(BindingMetadataProviderContext context)
|
||||
{
|
||||
if (_key.Equals(context.Key))
|
||||
{
|
||||
foreach (var action in _bindingActions)
|
||||
{
|
||||
action(context.BindingMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Apply(DisplayMetadataProviderContext context)
|
||||
{
|
||||
if (_key.Equals(context.Key))
|
||||
{
|
||||
foreach (var action in _displayActions)
|
||||
{
|
||||
action(context.DisplayMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Apply(ValidationMetadataProviderContext context)
|
||||
{
|
||||
if (_key.Equals(context.Key))
|
||||
{
|
||||
foreach (var action in _valiationActions)
|
||||
{
|
||||
action(context.ValidationMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IMetadataBuilder BindingDetails(Action<BindingMetadata> action)
|
||||
{
|
||||
_bindingActions.Add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IMetadataBuilder DisplayDetails(Action<DisplayMetadata> action)
|
||||
{
|
||||
_displayActions.Add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ValidationDetails(Action<ValidationMetadata> action)
|
||||
{
|
||||
_valiationActions.Add(action);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,10 @@
|
|||
"warningsAsErrors": "true"
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.FileProviders": "1.0.0-*",
|
||||
"Microsoft.AspNet.Http.Core": "1.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.ModelBinding": "",
|
||||
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
|
||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||
"Moq": "4.2.1312.1622",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
// 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 System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
{
|
||||
"resources": "TestFiles/**",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Mvc.ModelBinding": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.Razor.Host": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
|
||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.Framework.Runtime;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
|
@ -491,7 +492,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
[Theory]
|
||||
[MemberData(nameof(GetOrAdd_IgnoresCachedValue_IfGlobalWasChangedSinceCacheWasCreatedData))]
|
||||
public void GetOrAdd_IgnoresCachedValue_IfGlobalFileWasChangedSinceCacheWasCreated(
|
||||
RazorFileInfo viewStartRazorFileInfo, TestFileInfo globalFileInfo)
|
||||
RazorFileInfo viewStartRazorFileInfo, IFileInfo globalFileInfo)
|
||||
{
|
||||
// Arrange
|
||||
var expectedType = typeof(RuntimeCompileDifferent);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
// 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 System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
|
|
@ -1,182 +0,0 @@
|
|||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding.Metadata;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||
{
|
||||
public class TestModelMetadataProvider : DefaultModelMetadataProvider
|
||||
{
|
||||
// Creates a provider with all the defaults - includes data annotations
|
||||
public static IModelMetadataProvider CreateDefaultProvider()
|
||||
{
|
||||
var detailsProviders = new IMetadataDetailsProvider[]
|
||||
{
|
||||
new DefaultBindingMetadataProvider(),
|
||||
new DataAnnotationsMetadataDetailsProvider(),
|
||||
};
|
||||
|
||||
var compositeDetailsProvider = new DefaultCompositeMetadataDetailsProvider(detailsProviders);
|
||||
return new DefaultModelMetadataProvider(compositeDetailsProvider);
|
||||
}
|
||||
|
||||
private readonly TestModelMetadataDetailsProvider _detailsProvider;
|
||||
|
||||
public TestModelMetadataProvider()
|
||||
: this(new TestModelMetadataDetailsProvider())
|
||||
{
|
||||
}
|
||||
|
||||
private TestModelMetadataProvider(TestModelMetadataDetailsProvider detailsProvider)
|
||||
: base(new DefaultCompositeMetadataDetailsProvider(new IMetadataDetailsProvider[]
|
||||
{
|
||||
new DefaultBindingMetadataProvider(),
|
||||
new DataAnnotationsMetadataDetailsProvider(),
|
||||
detailsProvider
|
||||
}))
|
||||
{
|
||||
_detailsProvider = detailsProvider;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForType(Type type)
|
||||
{
|
||||
var key = ModelMetadataIdentity.ForType(type);
|
||||
|
||||
var builder = new MetadataBuilder(key);
|
||||
_detailsProvider.Builders.Add(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForType<TModel>()
|
||||
{
|
||||
return ForType(typeof(TModel));
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForProperty(Type containerType, string propertyName)
|
||||
{
|
||||
var property = containerType.GetRuntimeProperty(propertyName);
|
||||
Assert.NotNull(property);
|
||||
|
||||
var key = ModelMetadataIdentity.ForProperty(property.PropertyType, propertyName, containerType);
|
||||
|
||||
var builder = new MetadataBuilder(key);
|
||||
_detailsProvider.Builders.Add(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ForProperty<TContainer>(string propertyName)
|
||||
{
|
||||
return ForProperty(typeof(TContainer), propertyName);
|
||||
}
|
||||
|
||||
private class TestModelMetadataDetailsProvider :
|
||||
IBindingMetadataProvider,
|
||||
IDisplayMetadataProvider,
|
||||
IValidationMetadataProvider
|
||||
{
|
||||
public List<MetadataBuilder> Builders { get; } = new List<MetadataBuilder>();
|
||||
|
||||
public void GetBindingMetadata(BindingMetadataProviderContext context)
|
||||
{
|
||||
foreach (var builder in Builders)
|
||||
{
|
||||
builder.Apply(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetDisplayMetadata(DisplayMetadataProviderContext context)
|
||||
{
|
||||
foreach (var builder in Builders)
|
||||
{
|
||||
builder.Apply(context);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetValidationMetadata(ValidationMetadataProviderContext context)
|
||||
{
|
||||
foreach (var builder in Builders)
|
||||
{
|
||||
builder.Apply(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMetadataBuilder
|
||||
{
|
||||
IMetadataBuilder BindingDetails(Action<BindingMetadata> action);
|
||||
|
||||
IMetadataBuilder DisplayDetails(Action<DisplayMetadata> action);
|
||||
|
||||
IMetadataBuilder ValidationDetails(Action<ValidationMetadata> action);
|
||||
}
|
||||
|
||||
private class MetadataBuilder : IMetadataBuilder
|
||||
{
|
||||
private List<Action<BindingMetadata>> _bindingActions = new List<Action<BindingMetadata>>();
|
||||
private List<Action<DisplayMetadata>> _displayActions = new List<Action<DisplayMetadata>>();
|
||||
private List<Action<ValidationMetadata>> _valiationActions = new List<Action<ValidationMetadata>>();
|
||||
|
||||
private readonly ModelMetadataIdentity _key;
|
||||
|
||||
public MetadataBuilder(ModelMetadataIdentity key)
|
||||
{
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public void Apply(BindingMetadataProviderContext context)
|
||||
{
|
||||
if (_key.Equals(context.Key))
|
||||
{
|
||||
foreach (var action in _bindingActions)
|
||||
{
|
||||
action(context.BindingMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Apply(DisplayMetadataProviderContext context)
|
||||
{
|
||||
if (_key.Equals(context.Key))
|
||||
{
|
||||
foreach (var action in _displayActions)
|
||||
{
|
||||
action(context.DisplayMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Apply(ValidationMetadataProviderContext context)
|
||||
{
|
||||
if (_key.Equals(context.Key))
|
||||
{
|
||||
foreach (var action in _valiationActions)
|
||||
{
|
||||
action(context.ValidationMetadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IMetadataBuilder BindingDetails(Action<BindingMetadata> action)
|
||||
{
|
||||
_bindingActions.Add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IMetadataBuilder DisplayDetails(Action<DisplayMetadata> action)
|
||||
{
|
||||
_displayActions.Add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IMetadataBuilder ValidationDetails(Action<ValidationMetadata> action)
|
||||
{
|
||||
_valiationActions.Add(action);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Mvc.Razor": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
|
||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||
"Microsoft.Framework.Runtime": "1.0.0-*",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
|
||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||
"Microsoft.Framework.Logging.Interfaces": "1.0.0-*",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.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>f504357e-c2e1-4818-ba5c-9a2eac25fee5</ProjectGuid>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
|
|
@ -8,7 +8,7 @@ using Microsoft.AspNet.FileProviders;
|
|||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
public class TestFileInfo : IFileInfo
|
||||
internal class TestFileInfo : IFileInfo
|
||||
{
|
||||
private string _content;
|
||||
|
||||
|
|
@ -9,7 +9,7 @@ using Microsoft.Framework.Expiration.Interfaces;
|
|||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
public class TestFileProvider : IFileProvider
|
||||
internal class TestFileProvider : IFileProvider
|
||||
{
|
||||
private readonly Dictionary<string, IFileInfo> _lookup =
|
||||
new Dictionary<string, IFileInfo>(StringComparer.Ordinal);
|
||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
AddFile(path, fileInfo);
|
||||
}
|
||||
|
||||
public void AddFile(string path, TestFileInfo contents)
|
||||
public void AddFile(string path, IFileInfo contents)
|
||||
{
|
||||
_lookup[path] = contents;
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ using Microsoft.Framework.Expiration.Interfaces;
|
|||
|
||||
namespace Microsoft.AspNet.Mvc.Razor
|
||||
{
|
||||
public class TestFileTrigger : IExpirationTrigger
|
||||
internal class TestFileTrigger : IExpirationTrigger
|
||||
{
|
||||
public bool ActiveExpirationCallbacks { get; } = false;
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||
{
|
||||
public class TestModelMetadataProvider : DefaultModelMetadataProvider
|
||||
internal class TestModelMetadataProvider : DefaultModelMetadataProvider
|
||||
{
|
||||
// Creates a provider with all the defaults - includes data annotations
|
||||
public static IModelMetadataProvider CreateDefaultProvider()
|
||||
|
|
@ -30,7 +30,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
public TestModelMetadataProvider()
|
||||
: this(new TestModelMetadataDetailsProvider())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private TestModelMetadataProvider(TestModelMetadataDetailsProvider detailsProvider)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"version": "6.0.0-*",
|
||||
"shared": "*.cs",
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue