Changes to use moq-netcore

This commit is contained in:
Pranav K 2015-10-14 15:13:25 -07:00
parent 0832365ec2
commit 017bf1a20f
121 changed files with 458 additions and 490 deletions

View File

@ -27,8 +27,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
private readonly FileProviderGlobbingDirectory _baseGlobbingDirectory;
// Internal for testing
internal GlobbingUrlBuilder() { }
public GlobbingUrlBuilder() { }
/// <summary>
/// Creates a new <see cref="GlobbingUrlBuilder"/>.

View File

@ -331,7 +331,10 @@ namespace System.Net.Http
if (result?.Formatter == null)
{
// Return a 406 when we're actually performing conneg and it fails to find a formatter.
return request.CreateResponse(HttpStatusCode.NotAcceptable);
return new HttpResponseMessage(HttpStatusCode.NotAcceptable)
{
RequestMessage = request
};
}
else
{

View File

@ -4,15 +4,23 @@
"keyFile": "../../tools/Key.snk"
},
"dependencies": {
"Microsoft.AspNet.Mvc" : "6.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": { }
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}
}

View File

@ -14,7 +14,6 @@ using Microsoft.AspNet.Mvc.Controllers;
using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.Formatters;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.ModelBinding.Metadata;
using Microsoft.AspNet.Mvc.Routing;
using Microsoft.AspNet.Routing;
using Microsoft.AspNet.Routing.Constraints;
@ -1056,7 +1055,7 @@ namespace Microsoft.AspNet.Mvc.Description
action.ControllerTypeInfo = controllerType.GetTypeInfo();
action.BoundProperties = new List<ParameterDescriptor>();
foreach (var property in action.ControllerTypeInfo.GetProperties())
foreach (var property in controllerType.GetProperties())
{
var bindingInfo = BindingInfo.GetBindingInfo(property.GetCustomAttributes().OfType<object>());
if (bindingInfo != null)

View File

@ -11,13 +11,21 @@
},
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": { }
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}

View File

@ -97,7 +97,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
// Ensure non-default value
Assert.NotEmpty((IDictionary<object, object>)value1);
}
else if (property.PropertyType.IsValueType ||
else if (property.PropertyType.GetTypeInfo().IsValueType ||
Nullable.GetUnderlyingType(property.PropertyType) != null)
{
Assert.Equal(value1, value2);

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.AspNet.Routing;
using Xunit;
@ -28,14 +29,14 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var value1 = property.GetValue(route);
var value2 = property.GetValue(route2);
if (typeof(IEnumerable<object>).IsAssignableFrom(property.PropertyType))
if (typeof(IEnumerable<object>).GetTypeInfo().IsAssignableFrom(property.PropertyType.GetTypeInfo()))
{
Assert.Equal<object>((IEnumerable<object>)value1, (IEnumerable<object>)value2);
// Ensure non-default value
Assert.NotEmpty((IEnumerable<object>)value1);
}
else if (property.PropertyType.IsValueType ||
else if (property.PropertyType.GetTypeInfo().IsValueType ||
Nullable.GetUnderlyingType(property.PropertyType) != null)
{
Assert.Equal(value1, value2);

View File

@ -101,7 +101,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
// Ensure non-default value
Assert.NotEmpty((IDictionary<object, object>)value1);
}
else if (property.PropertyType.IsValueType ||
else if (property.PropertyType.GetTypeInfo().IsValueType ||
Nullable.GetUnderlyingType(property.PropertyType) != null)
{
Assert.Equal(value1, value2);

View File

@ -266,7 +266,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var typeInfo = typeof(DerivedController).GetTypeInfo();
var methodInfo =
typeInfo.GetRuntimeInterfaceMap(typeof(IDisposable)).TargetMethods[0];
var method = typeInfo.GetMethods().Where(m => (m == methodInfo)).SingleOrDefault();
var method = typeInfo.AsType().GetMethods().SingleOrDefault(m => (m == methodInfo));
Assert.NotNull(method);
// Act
@ -284,7 +284,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var typeInfo = typeof(DerivedController).GetTypeInfo();
var methodInfo =
typeInfo.GetRuntimeInterfaceMap(typeof(IDisposable)).TargetMethods[0];
var methods = typeInfo.GetMethods().Where(m => m.Name.Equals("Dispose") && m != methodInfo);
var methods = typeInfo.AsType().GetMethods().Where(m => m.Name.Equals("Dispose") && m != methodInfo);
Assert.NotEmpty(methods);
@ -338,7 +338,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var typeInfo = typeof(IDisposablePocoController).GetTypeInfo();
var methodInfo =
typeInfo.GetRuntimeInterfaceMap(typeof(IDisposable)).TargetMethods[0];
var method = typeInfo.GetMethods().Where(m => (m == methodInfo)).SingleOrDefault();
var method = typeInfo.AsType().GetMethods().SingleOrDefault(m => (m == methodInfo));
Assert.NotNull(method);
// Act
@ -356,7 +356,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var typeInfo = typeof(IDisposablePocoController).GetTypeInfo();
var methodInfo =
typeInfo.GetRuntimeInterfaceMap(typeof(IDisposable)).TargetMethods[0];
var methods = typeInfo.GetMethods().Where(m => m.Name.Equals("Dispose") && m != methodInfo);
var methods = typeInfo.AsType().GetMethods().Where(m => m.Name.Equals("Dispose") && m != methodInfo);
Assert.NotEmpty(methods);
@ -376,7 +376,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
// Arrange
var builder = new TestApplicationModelProvider();
var typeInfo = typeof(SimplePocoController).GetTypeInfo();
var methods = typeInfo.GetMethods().Where(m => m.Name.Equals("Dispose"));
var methods = typeInfo.AsType().GetMethods().Where(m => m.Name.Equals("Dispose"));
Assert.NotEmpty(methods);
@ -419,7 +419,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(ConventionallyRoutedController.Edit);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -438,7 +438,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(ConventionallyRoutedController.Update);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -459,7 +459,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(ConventionallyRoutedController.Delete);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -481,7 +481,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(ConventionallyRoutedController.Details);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -501,7 +501,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(ConventionallyRoutedController.List);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -521,7 +521,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(NoRouteAttributeOnControllerController.Edit);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -546,7 +546,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(NoRouteAttributeOnControllerController.Update);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -570,7 +570,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(NoRouteAttributeOnControllerController.List);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -594,7 +594,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(NoRouteAttributeOnControllerController.Index);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
Assert.Equal(2, actions.Count());
@ -625,7 +625,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(NoRouteAttributeOnControllerController.Remove);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -649,7 +649,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var typeInfo = controller.GetTypeInfo();
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod("Delete"));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod("Delete"));
// Assert
var action = Assert.Single(actions);
@ -673,7 +673,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var typeInfo = controller.GetTypeInfo();
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod("Index"));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod("Index"));
// Assert
Assert.Equal(2, actions.Count());
@ -703,7 +703,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(MixedHttpVerbsAndRouteAttributeController.VerbAndRoute);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
var action = Assert.Single(actions);
@ -720,7 +720,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(MixedHttpVerbsAndRouteAttributeController.MultipleVerbsAndRoutes);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
Assert.Equal(2, actions.Count());
@ -742,7 +742,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(MixedHttpVerbsAndRouteAttributeController.MultipleVerbsWithAnyWithoutTemplateAndRoutes);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
Assert.Equal(3, actions.Count());
@ -766,7 +766,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(MixedHttpVerbsAndRouteAttributeController.Invalid);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
Assert.Equal(2, actions.Count());
@ -787,7 +787,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(DerivedClassInheritsAttributeRoutesController.Edit);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
Assert.Equal(2, actions.Count());
@ -810,7 +810,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
var actionName = nameof(DerivedClassOverridesAttributeRoutesController.Edit);
// Act
var actions = builder.BuildActionModels(typeInfo, typeInfo.GetMethod(actionName));
var actions = builder.BuildActionModels(typeInfo, typeInfo.AsType().GetMethod(actionName));
// Assert
Assert.Equal(2, actions.Count());

View File

@ -3,8 +3,8 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.ModelBinding.Metadata;
using Xunit;
namespace Microsoft.AspNet.Mvc.ApplicationModels
@ -56,7 +56,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
// Ensure non-default value
Assert.NotEmpty((IDictionary<object, object>)value1);
}
else if (property.PropertyType.IsValueType ||
else if (property.PropertyType.GetTypeInfo().IsValueType ||
Nullable.GetUnderlyingType(property.PropertyType) != null)
{
Assert.Equal(value1, value2);

View File

@ -52,7 +52,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels
// Ensure non-default value
Assert.NotEmpty((IDictionary<object, object>)value1);
}
else if (property.PropertyType.IsValueType ||
else if (property.PropertyType.GetTypeInfo().IsValueType ||
Nullable.GetUnderlyingType(property.PropertyType) != null)
{
Assert.Equal(value1, value2);

View File

@ -3,9 +3,7 @@
using System;
using Microsoft.AspNet.Http.Internal;
#if DNX451
using Moq;
#endif
using Xunit;
namespace Microsoft.AspNet.Mvc.ModelBinding
@ -63,7 +61,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
Assert.Equal(isIncluded, predicate(context, property));
}
#if DNX451
[Theory]
[InlineData("UserName", true)]
[InlineData("Username", false)]
@ -120,7 +117,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
Assert.True(predicate(context, "UserName"));
Assert.True(predicate(context, "UserName"));
}
#endif
private class TestProvider : IPropertyBindingPredicateProvider
{

View File

@ -590,7 +590,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
Func<object, int> method = foo => 1;
return new ControllerActionDescriptor
{
MethodInfo = method.Method,
MethodInfo = method.GetMethodInfo(),
ControllerTypeInfo = typeof(TestController).GetTypeInfo(),
BoundProperties = new List<ParameterDescriptor>(),
Parameters = new List<ParameterDescriptor>()

View File

@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
typeof(TestController).GetTypeInfo(),
new List<object>() { });
var propertyInfo = controller.ControllerType.GetProperty("BoundProperty");
var propertyInfo = controller.ControllerType.AsType().GetProperty("BoundProperty");
controller.ControllerProperties.Add(
new PropertyModel(
propertyInfo,
@ -32,7 +32,9 @@ namespace Microsoft.AspNet.Mvc.Controllers
});
controller.ControllerProperties.Add(
new PropertyModel(controller.ControllerType.GetProperty("UnboundProperty"), new List<object>() { }));
new PropertyModel(
controller.ControllerType.AsType().GetProperty("UnboundProperty"),
new List<object>() { }));
controller.Application = applicationModel;
applicationModel.Controllers.Add(controller);

View File

@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.Controllers
public class ControllerActionInvokerTest
{
// Intentionally choosing an uncommon exception type.
private readonly Exception _actionException = new TimeZoneNotFoundException();
private readonly Exception _actionException = new DivideByZeroException();
private readonly ContentResult _result = new ContentResult() { Content = "Hello, world!" };

View File

@ -23,8 +23,8 @@ namespace Microsoft.AspNet.Mvc
var controllerTypes = new[]
{
typeof(ControllerTypeA).GetTypeInfo(),
typeof(TypeBController).GetTypeInfo(),
typeof(ControllerTypeA),
typeof(TypeBController),
};
// Act
@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal(typeof(IControllerTypeProvider), services[3].ServiceType);
var typeProvider = Assert.IsType<StaticControllerTypeProvider>(services[3].ImplementationInstance);
Assert.Equal(controllerTypes, typeProvider.ControllerTypes.OrderBy(c => c.Name));
Assert.Equal(controllerTypes, typeProvider.ControllerTypes.OrderBy(c => c.Name).Select(t => t.AsType()));
Assert.Equal(ServiceLifetime.Singleton, services[3].Lifetime);
}
}

View File

@ -3,7 +3,6 @@
using System;
using System.IO;
using System.Net.Mime;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Internal;
@ -275,7 +274,7 @@ namespace Microsoft.AspNet.Mvc
public bool WasWriteFileCalled;
public EmptyFileResult()
: base(MediaTypeHeaderValue.Parse(MediaTypeNames.Application.Octet))
: base(MediaTypeHeaderValue.Parse("application/octet"))
{
}

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System.Threading.Tasks;
using Moq;
using Xunit;
@ -41,4 +40,3 @@ namespace Microsoft.AspNet.Mvc.Filters
}
}
}
#endif

View File

@ -8,13 +8,9 @@ using Microsoft.AspNet.Mvc.Infrastructure;
using Microsoft.AspNet.Routing;
using Microsoft.Extensions.OptionsModel;
using Microsoft.Net.Http.Headers;
#if DNX451
using Moq;
#endif
using Xunit;
namespace Microsoft.AspNet.Mvc.Formatters
{
public class FormatFilterTests
@ -26,7 +22,6 @@ namespace Microsoft.AspNet.Mvc.Formatters
RouteAndQueryData
}
#if DNX451
[Theory]
[InlineData("json", FormatSource.RouteData, "application/json")]
[InlineData("json", FormatSource.QueryData, "application/json")]
@ -405,6 +400,5 @@ namespace Microsoft.AspNet.Mvc.Formatters
};
}
}
#endif
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. 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.IO;
using System.Text;
using System.Threading;
@ -33,6 +32,7 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal(expectedData, memoryStream.ToArray());
}
#if DNX451
[Fact]
public async Task DoesNotFlush_UnderlyingStream_OnClosingWriter()
{
@ -48,6 +48,7 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal(0, stream.FlushCallCount);
Assert.Equal(0, stream.FlushAsyncCallCount);
}
#endif
[Fact]
public async Task DoesNotFlush_UnderlyingStream_OnDisposingWriter()
@ -65,6 +66,7 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal(0, stream.FlushAsyncCallCount);
}
#if DNX451
[Fact]
public async Task DoesNotClose_UnderlyingStream_OnDisposingWriter()
{
@ -79,6 +81,7 @@ namespace Microsoft.AspNet.Mvc
// Assert
Assert.Equal(0, stream.CloseCallCount);
}
#endif
[Fact]
public async Task DoesNotDispose_UnderlyingStream_OnDisposingWriter()
@ -108,7 +111,11 @@ namespace Microsoft.AspNet.Mvc
await writer.WriteAsync(new string('a', byteLength));
// Act
#if DNX451
writer.Close();
#else
writer.Dispose();
#endif
// Assert
Assert.Equal(0, stream.FlushCallCount);
@ -299,7 +306,10 @@ namespace Microsoft.AspNet.Mvc
[Theory]
[InlineData("你好世界", "utf-16")]
#if !DNXCORE50
// CoreCLR does not like shift_jis as an encoding.
[InlineData("こんにちは世界", "shift_jis")]
#endif
[InlineData("హలో ప్రపంచ", "iso-8859-1")]
[InlineData("வணக்கம் உலக", "utf-32")]
public async Task WritesData_InExpectedEncoding(string data, string encodingName)
@ -327,9 +337,12 @@ namespace Microsoft.AspNet.Mvc
[InlineData('你', 1023, "utf-16")]
[InlineData('你', 1024, "utf-16")]
[InlineData('你', 1050, "utf-16")]
#if !DNXCORE50
// CoreCLR does not like shift_jis as an encoding.
[InlineData('こ', 1023, "shift_jis")]
[InlineData('こ', 1024, "shift_jis")]
[InlineData('こ', 1050, "shift_jis")]
#endif
[InlineData('హ', 1023, "iso-8859-1")]
[InlineData('హ', 1024, "iso-8859-1")]
[InlineData('హ', 1050, "iso-8859-1")]
@ -467,14 +480,13 @@ namespace Microsoft.AspNet.Mvc
{
private int _flushCallCount;
private int _flushAsyncCallCount;
private int _closeCallCount;
private int _disposeCallCount;
public int FlushCallCount { get { return _flushCallCount; } }
public int FlushAsyncCallCount { get { return _flushAsyncCallCount; } }
public int CloseCallCount { get { return _closeCallCount; } }
public int CloseCallCount { get; private set; }
public int DisposeCallCount { get { return _disposeCallCount; } }
@ -490,11 +502,13 @@ namespace Microsoft.AspNet.Mvc
return base.FlushAsync(cancellationToken);
}
#if DNX451
public override void Close()
{
_closeCallCount++;
CloseCallCount++;
base.Close();
}
#endif
protected override void Dispose(bool disposing)
{

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
@ -15,7 +14,7 @@ using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.Controllers;
using Microsoft.AspNet.Mvc.Routing;
using Microsoft.AspNet.Routing;
using Microsoft.Extensions.Internal;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
using Moq;
@ -635,21 +634,22 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
{
var actionDescriptorProvider = GetActionDescriptorProvider();
// service container does not work quite like our built in Depenency Injection container.
var serviceContainer = new ServiceContainer();
var serviceContainer = new ServiceCollection();
var list = new List<IActionDescriptorProvider>()
{
actionDescriptorProvider,
};
serviceContainer.AddService(typeof(IEnumerable<IActionDescriptorProvider>), list);
serviceContainer.AddSingleton(typeof(IEnumerable<IActionDescriptorProvider>), list);
var actionCollectionDescriptorProvider = new DefaultActionDescriptorsCollectionProvider(serviceContainer);
var actionCollectionDescriptorProvider = new DefaultActionDescriptorsCollectionProvider(
serviceContainer.BuildServiceProvider());
var decisionTreeProvider = new ActionSelectorDecisionTreeProvider(actionCollectionDescriptorProvider);
var actionConstraintProviders = new IActionConstraintProvider[] {
new DefaultActionConstraintProvider(),
};
var actionConstraintProviders = new[]
{
new DefaultActionConstraintProvider(),
};
var defaultActionSelector = new DefaultActionSelector(
actionCollectionDescriptorProvider,
@ -761,7 +761,7 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
var routeData = new RouteData();
routeData.Routers.Add(new Mock<IRouter>(MockBehavior.Strict).Object);
var serviceContainer = new ServiceContainer();
var serviceProvider = new ServiceCollection().BuildServiceProvider();
var httpContext = new Mock<HttpContext>(MockBehavior.Strict);
@ -770,7 +770,7 @@ namespace Microsoft.AspNet.Mvc.Infrastructure
request.SetupGet(r => r.Path).Returns(new PathString());
request.SetupGet(r => r.Headers).Returns(new HeaderDictionary());
httpContext.SetupGet(c => c.Request).Returns(request.Object);
httpContext.SetupGet(c => c.RequestServices).Returns(serviceContainer);
httpContext.SetupGet(c => c.RequestServices).Returns(serviceProvider);
return new RouteContext(httpContext.Object)
{

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;
@ -231,4 +230,4 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;
@ -146,4 +145,3 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
}
}
}
#endif

View File

@ -3,23 +3,18 @@
using System;
using System.Collections.Generic;
#if DNX451
using System.Globalization;
using System.Linq;
#endif
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.ModelBinding.Validation;
#if DNX451
using Moq;
#endif
using Xunit;
namespace Microsoft.AspNet.Mvc.ModelBinding.Test
{
public class CollectionModelBinderTest
{
#if DNX451
[Fact]
public async Task BindComplexCollectionFromIndexes_FiniteIndexes()
{
@ -205,7 +200,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
var model = Assert.IsType<List<int>>(result.Model);
Assert.Empty(model);
}
#endif
[Fact]
public async Task BindSimpleCollection_RawValueIsEmptyCollection_ReturnsEmptyList()
@ -342,7 +336,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
Assert.Equal(expectedResult, result);
}
#if DNX451
[Fact]
public async Task BindSimpleCollection_SubBindingSucceeds()
{
@ -418,7 +411,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
});
return mockIntBinder.Object;
}
#endif
private static ModelBindingContext CreateContext()
{
@ -462,7 +454,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
public ListWithThrowingConstructor()
: base()
{
throw new ApplicationException("No, don't do this.");
throw new RankException("No, don't do this.");
}
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -598,4 +597,3 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
}
}
}
#endif

View File

@ -1,17 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
#endif
using System.Collections.Generic;
using System.Globalization;
#if DNX451
using System.Threading.Tasks;
using Microsoft.Extensions.Primitives;
using Moq;
using Xunit;
#endif
namespace Microsoft.AspNet.Mvc.ModelBinding
{
@ -29,7 +25,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
return new CompositeValueProvider() { emptyValueProvider, valueProvider };
}
#if DNX451
[Fact]
public void GetKeysFromPrefixAsync_ReturnsResultFromFirstValueProviderThatReturnsValues()
{
@ -142,6 +137,5 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
}
}
#endif
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.Globalization;
@ -565,9 +564,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
public DictionaryWithThrowingConstructor()
: base()
{
throw new ApplicationException("No, don't do this.");
throw new RankException("No, don't do this.");
}
}
}
}
#endif

View File

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.Threading;
@ -139,5 +137,3 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
}
}
#endif

View File

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.Threading;
@ -267,5 +265,3 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@ -278,4 +277,3 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
}
}
}
#endif

View File

@ -6,9 +6,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
#if !DNXCORE50
using Moq;
#endif
using Xunit;
namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
@ -267,7 +265,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
Assert.True(isRequired);
}
#if !DNXCORE50
[Fact]
public void PropertiesProperty_CallsProvider()
{
@ -485,7 +482,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata
Assert.Equal(expectedNames.Count(), properties.Count);
Assert.Equal(expectedNames.ToArray(), properties.Select(p => p.PropertyName).ToArray());
}
#endif
[Fact]
public void PropertiesSetOnce()

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -1399,4 +1398,3 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -1919,4 +1918,3 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
@ -10,15 +9,11 @@ using Microsoft.AspNet.Mvc.Abstractions;
using Microsoft.AspNet.Routing;
using Moq;
using Xunit;
#endif
namespace Microsoft.AspNet.Mvc.ModelBinding.Test
{
public class QueryStringValueProviderFactoryTest
{
private readonly QueryStringValueProviderFactory _factory = new QueryStringValueProviderFactory();
#if DNX451
[Fact]
public async Task GetValueProvider_ReturnsQueryStringValueProviderInstanceWithInvariantCulture()
{
@ -29,14 +24,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
context.SetupGet(c => c.Items).Returns(new Dictionary<object, object>());
context.SetupGet(c => c.Request).Returns(request.Object);
var actionContext = new ActionContext(context.Object, new RouteData(), new ActionDescriptor());
var factory = new QueryStringValueProviderFactory();
// Act
var result = await _factory.GetValueProviderAsync(actionContext);
var result = await factory.GetValueProviderAsync(actionContext);
// Assert
var valueProvider = Assert.IsType<QueryStringValueProvider>(result);
Assert.Equal(CultureInfo.InvariantCulture, valueProvider.Culture);
}
#endif
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System.Linq;
using Moq;
using Xunit;
@ -47,4 +46,3 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
}
}
}
#endif

View File

@ -1,11 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
#if DNXCORE50
using System.Reflection;
#endif
using Microsoft.AspNet.Testing;
using Moq;
using Xunit;
@ -991,4 +993,3 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
}
}
}
#endif

View File

@ -1,16 +1,15 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc.Core;
using Xunit;
namespace Microsoft.AspNet.Mvc.Internal
{
public class NonDisposableStreamTest
{
#if DNX451
[Fact]
public void InnerStreamIsOpenOnClose()
{
@ -24,6 +23,7 @@ namespace Microsoft.AspNet.Mvc.Internal
// Assert
Assert.True(innerStream.CanRead);
}
#endif
[Fact]
public void InnerStreamIsOpenOnDispose()
@ -49,6 +49,7 @@ namespace Microsoft.AspNet.Mvc.Internal
nonDisposableStream.Dispose();
}
#if DNX451
[Fact]
public void InnerStreamIsNotFlushedOnClose()
{
@ -60,6 +61,7 @@ namespace Microsoft.AspNet.Mvc.Internal
// Act & Assert
nonDisposableStream.Close();
}
#endif
[Fact]
public void InnerStreamIsNotFlushedOnFlush()
@ -86,4 +88,3 @@ namespace Microsoft.AspNet.Mvc.Internal
}
}
}
#endif

View File

@ -10,9 +10,7 @@ using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.Formatters;
using Microsoft.AspNet.Routing;
using Microsoft.Net.Http.Headers;
#if DNX451
using Moq;
#endif
using Xunit;
namespace Microsoft.AspNet.Mvc.Test

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
@ -111,4 +110,3 @@ namespace Microsoft.AspNet.Mvc.Routing
}
}
}
#endif

View File

@ -1,9 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
#if DNXCORE50
using System.Reflection;
#endif
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Abstractions;
@ -213,4 +215,3 @@ namespace Microsoft.AspNet.Mvc.Routing
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Http;
@ -208,4 +207,3 @@ namespace Microsoft.AspNet.Mvc.Routing
}
}
}
#endif

View File

@ -19,7 +19,6 @@
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
@ -27,7 +26,14 @@
},
"frameworks": {
"dnx451": {
"compilationOptions": { "define": [ "MOCK_SUPPORT" ] }
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}
}

View File

@ -1,22 +1,33 @@
{
"compilationOptions": {
"warningsAsErrors": true
"compilationOptions": {
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
},
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml" : "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": { }
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}
}

View File

@ -1,13 +1,9 @@
// Copyright (c) .NET Foundation. 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.ComponentModel.DataAnnotations;
using System.Linq;
#if DNX451
using Moq;
#endif
using Xunit;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
@ -16,7 +12,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{
private readonly IModelMetadataProvider _metadataProvider = TestModelMetadataProvider.CreateDefaultProvider();
#if DNX451
[Fact]
public void GetValidators_ReturnsValidatorForIValidatableObject()
{
@ -36,7 +31,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
var validator = Assert.Single(providerContext.Validators);
Assert.IsType<ValidatableObjectAdapter>(validator);
}
#endif
[Fact]
public void GetValidators_InsertsRequiredValidatorsFirst()
@ -89,7 +83,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
// Default IValidatableObject adapter factory
#if DNX451
[Fact]
public void IValidatableObjectGetsAValidator()
{
@ -108,7 +101,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
// Assert
Assert.Single(providerContext.Validators);
}
#endif
private class ObservableModel
{

View File

@ -3,14 +3,9 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
#if DNX451
using System.Linq;
#endif
using Microsoft.Extensions.Localization;
#if DNX451
using Moq;
using Moq.Protected;
#endif
using Xunit;
namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
@ -26,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
var attribute = new RequiredAttribute();
// Act
var validator = new DataAnnotationsModelValidator(attribute, stringLocalizer : null);
var validator = new DataAnnotationsModelValidator(attribute, stringLocalizer: null);
// Assert
Assert.Same(attribute, validator.Attribute);
@ -54,7 +49,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
}
}
#if DNX451
[Theory]
[MemberData(nameof(Validate_SetsMemberName_OnValidationContext_ForProperties_Data))]
public void Validate_SetsMemberName_OnValidationContext_ForProperties(
@ -64,15 +58,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
string expectedMemberName)
{
// Arrange
var attribute = new Mock<ValidationAttribute> { CallBase = true };
attribute.Protected()
.Setup<ValidationResult>("IsValid", ItExpr.IsAny<object>(), ItExpr.IsAny<ValidationContext>())
.Callback((object o, ValidationContext context) =>
{
Assert.Equal(expectedMemberName, context.MemberName);
})
.Returns(ValidationResult.Success)
.Verifiable();
var attribute = new Mock<TestableValidationAttribute> { CallBase = true };
attribute
.Setup(p => p.IsValidPublic(It.IsAny<object>(), It.IsAny<ValidationContext>()))
.Callback((object o, ValidationContext context) =>
{
Assert.Equal(expectedMemberName, context.MemberName);
})
.Returns(ValidationResult.Success)
.Verifiable();
var validator = new DataAnnotationsModelValidator(attribute.Object, stringLocalizer: null);
var validationContext = new ModelValidationContext()
{
@ -151,10 +145,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
var container = "Hello";
var model = container.Length;
var attribute = new Mock<ValidationAttribute> { CallBase = true };
attribute.Protected()
.Setup<ValidationResult>("IsValid", ItExpr.IsAny<object>(), ItExpr.IsAny<ValidationContext>())
.Returns(ValidationResult.Success);
var attribute = new Mock<TestableValidationAttribute> { CallBase = true };
attribute
.Setup(p => p.IsValidPublic(It.IsAny<object>(), It.IsAny<ValidationContext>()))
.Returns(ValidationResult.Success);
var validator = new DataAnnotationsModelValidator(attribute.Object, stringLocalizer: null);
var validationContext = new ModelValidationContext()
{
@ -180,10 +174,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
var container = "Hello";
var model = container.Length;
var attribute = new Mock<ValidationAttribute> { CallBase = true };
attribute.Protected()
.Setup<ValidationResult>("IsValid", ItExpr.IsAny<object>(), ItExpr.IsAny<ValidationContext>())
.Returns(new ValidationResult(errorMessage, memberNames: null));
var attribute = new Mock<TestableValidationAttribute> { CallBase = true };
attribute
.Setup(p => p.IsValidPublic(It.IsAny<object>(), It.IsAny<ValidationContext>()))
.Returns(new ValidationResult(errorMessage, memberNames: null));
var validator = new DataAnnotationsModelValidator(attribute.Object, stringLocalizer: null);
var validationContext = new ModelValidationContext()
@ -211,10 +205,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
var metadata = _metadataProvider.GetMetadataForType(typeof(object));
var model = new object();
var attribute = new Mock<ValidationAttribute> { CallBase = true };
attribute.Protected()
.Setup<ValidationResult>("IsValid", ItExpr.IsAny<object>(), ItExpr.IsAny<ValidationContext>())
.Returns(new ValidationResult(errorMessage, new[] { "FirstName" }));
var attribute = new Mock<TestableValidationAttribute> { CallBase = true };
attribute
.Setup(p => p.IsValidPublic(It.IsAny<object>(), It.IsAny<ValidationContext>()))
.Returns(new ValidationResult(errorMessage, new[] { "FirstName" }));
var validator = new DataAnnotationsModelValidator(attribute.Object, stringLocalizer: null);
var validationContext = new ModelValidationContext()
@ -239,10 +233,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
var metadata = _metadataProvider.GetMetadataForType(typeof(SampleModel));
var model = new SampleModel();
var attribute = new Mock<ValidationAttribute> { CallBase = true };
attribute.Protected()
.Setup<ValidationResult>("IsValid", ItExpr.IsAny<object>(), ItExpr.IsAny<ValidationContext>())
.Returns(new ValidationResult("Name error", new[] { "Name" }));
var attribute = new Mock<TestableValidationAttribute> { CallBase = true };
attribute
.Setup(p => p.IsValidPublic(It.IsAny<object>(), It.IsAny<ValidationContext>()))
.Returns(new ValidationResult("Name error", new[] { "Name" }));
var validator = new DataAnnotationsModelValidator(attribute.Object, stringLocalizer: null);
var validationContext = new ModelValidationContext()
@ -292,12 +286,21 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
Assert.Equal("", validationResult.MemberName);
Assert.Equal("Longueur est invalide", validationResult.Message);
}
#endif
private class DerivedRequiredAttribute : RequiredAttribute
{
}
public abstract class TestableValidationAttribute : ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
return IsValidPublic(value, validationContext);
}
public abstract ValidationResult IsValidPublic(object value, ValidationContext validationContext);
}
private class SampleModel
{
public string Name { get; set; }

View File

@ -62,7 +62,6 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
Assert.Equal("Length must be at most 5", rule.ErrorMessage);
}
#if DNX451
[Fact]
[ReplaceCulture]
public void ClientRulesWithMaxLengthAttribute_StringLocalizer_ReturnsLocalizedErrorString()
@ -93,6 +92,5 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
Assert.Equal(10, rule.ValidationParameters["max"]);
Assert.Equal("Longueur est invalide", rule.ErrorMessage);
}
#endif
}
}
}

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Globalization;
using Microsoft.AspNet.Mvc.DataAnnotations.Test;
namespace Microsoft.AspNet.Mvc.ModelBinding
@ -15,9 +15,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public static string DisplayAttribute_Name { get; } = Resources.DisplayAttribute_Name;
public static string DisplayAttribute_CultureSensitiveName =>
Resources.DisplayAttribute_Name + Thread.CurrentThread.CurrentUICulture;
Resources.DisplayAttribute_Name + CultureInfo.CurrentUICulture;
public static string DisplayAttribute_CultureSensitiveDescription =>
Resources.DisplayAttribute_Description + Thread.CurrentThread.CurrentUICulture;
Resources.DisplayAttribute_Description + CultureInfo.CurrentUICulture;
}
}

View File

@ -1,22 +1,33 @@
{
"compilationOptions": {
"warningsAsErrors": true,
"keyFile": "../../tools/Key.snk"
"compilationOptions": {
"warningsAsErrors": true,
"keyFile": "../../tools/Key.snk"
},
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
},
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": { }
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.Collections.Generic;
using System.IO;
@ -414,4 +413,3 @@ namespace Microsoft.AspNet.Mvc.Formatters
}
}
}
#endif

View File

@ -215,15 +215,21 @@ namespace Microsoft.AspNet.Mvc.Formatters
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-8", "utf-8", true },
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-16", "utf-16", true },
{ "This is a test 激光這兩個字是甚麼意思 string written using utf-32", "utf-32", false },
#if !DNXCORE50
// CoreCLR does not like shift_jis as an encoding.
{ "This is a test 激光這兩個字是甚麼意思 string written using shift_jis", "shift_jis", false },
#endif
{ "This is a test æøå string written using iso-8859-1", "iso-8859-1", false },
};
#if !DNXCORE50
// CoreCLR does not like iso-2022-kr as an encoding.
if (!TestPlatformHelper.IsMono)
{
// Mono issue - https://github.com/aspnet/External/issues/28
data.Add("This is a test 레이저 단어 뜻 string written using iso-2022-kr", "iso-2022-kr", false);
}
#endif
return data;
}

View File

@ -1,22 +1,33 @@
{
"compilationOptions": {
"warningsAsErrors": true
"compilationOptions": {
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
},
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": { }
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}
}

View File

@ -223,8 +223,9 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
}
[ConditionalFact]
// Mono issue - https://github.com/aspnet/External/issues/18
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[FrameworkSkipCondition(RuntimeFrameworks.Mono | RuntimeFrameworks.CoreCLR,
SkipReason = "Mono issue - https://github.com/aspnet/External/issues/18; " +
"CoreCLR issue - https://github.com/aspnet/External/issues/51")]
public async Task ReadAsync_ThrowsOnExceededMaxDepth()
{
// Arrange
@ -242,8 +243,9 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
}
[ConditionalFact]
// Mono issue - https://github.com/aspnet/External/issues/18
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[FrameworkSkipCondition(RuntimeFrameworks.Mono | RuntimeFrameworks.CoreCLR,
SkipReason = "Mono issue - https://github.com/aspnet/External/issues/18; " +
"CoreCLR issue - https://github.com/aspnet/External/issues/51")]
public async Task ReadAsync_ThrowsWhenReaderQuotasAreChanged()
{
// Arrange

View File

@ -426,6 +426,9 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
}
}
#if !DNXCORE50
// DataContractSerializer in CoreCLR does not throw if the declared type is different from the type being
// serialized.
[ConditionalFact]
// Mono issue - https://github.com/aspnet/External/issues/18
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
@ -440,6 +443,27 @@ namespace Microsoft.AspNet.Mvc.Formatters.Xml
await Assert.ThrowsAsync(typeof(SerializationException),
async () => await formatter.WriteAsync(outputFormatterContext));
}
#else
[Fact]
public async Task WriteAsync_SerializesObjectWhenDeclaredTypeIsDifferentFromActualType()
{
// Arrange
var expected = @"<DummyClass xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"" xmlns="""" " +
@"i:type=""SomeDummyClass""><SampleInt>1</SampleInt><SampleString>Test</SampleString></DummyClass>";
var sampleInput = new SomeDummyClass { SampleInt = 1, SampleString = "Test" };
var formatter = new XmlDataContractSerializerOutputFormatter();
var outputFormatterContext = GetOutputFormatterContext(sampleInput, typeof(DummyClass));
// Act
await formatter.WriteAsync(outputFormatterContext);
// Assert
var body = outputFormatterContext.HttpContext.Response.Body;
body.Position = 0;
var actual = new StreamReader(body).ReadToEnd();
XmlAssert.Equal(expected, actual);
}
#endif
[ConditionalFact]
// Mono issue - https://github.com/aspnet/External/issues/18

View File

@ -6,16 +6,27 @@
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml" : "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "type": "build", "version": "6.0.0-*" },
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"type": "build",
"version": "6.0.0-*"
},
"Microsoft.AspNet.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": { }
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}
}

View File

@ -3,7 +3,7 @@
"../Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlAssert.cs"
],
"compilationOptions": {
"define": [ "__RemoveThisBitTo__GENERATE_BASELINES" ],
"define": [ "__RemoveThisBitTo__GENERATE_BASELINES", "FUNCTIONAL_TESTS" ],
"warningsAsErrors": true
},
"dependencies": {

View File

@ -1,27 +1,31 @@
{
"compilationOptions": {
"warningsAsErrors": true
"compilationOptions": {
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
},
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "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-*"
"Microsoft.AspNet.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"commands": {
"test": "xunit.runner.aspnet"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": { }
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}
}

View File

@ -19,8 +19,13 @@
"frameworks": {
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}
}

View File

@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{
public class MvcRazorHostTest
{
private static Assembly _assembly = typeof(MvcRazorHostTest).Assembly;
private static Assembly _assembly = typeof(MvcRazorHostTest).GetTypeInfo().Assembly;
public static TheoryData NormalizeChunkInheritanceUtilityPaths_Data
{

View File

@ -26,6 +26,11 @@
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
},
"exclude": [
@ -33,4 +38,4 @@
"node_modules",
"bower_components"
]
}
}

View File

@ -4,13 +4,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.Dnx.Compilation.CSharp;
using Microsoft.Extensions.CompilationAbstractions;
using Microsoft.Extensions.PlatformAbstractions;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
namespace Microsoft.AspNet.Mvc.Razor.Compilation
@ -456,10 +457,20 @@ public class Person
private CSharpCompilation Compile(SyntaxTree tree)
{
// Disable 1702 until roslyn turns this off by default
var options = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
.WithSpecificDiagnosticOptions(new Dictionary<string, ReportDiagnostic>
{
{ "CS1701", ReportDiagnostic.Suppress }, // Binding redirects
{ "CS1702", ReportDiagnostic.Suppress },
{ "CS1705", ReportDiagnostic.Suppress }
});
var compilation = CSharpCompilation.Create(
"Test.Assembly",
new[] { tree },
GetReferences());
GetReferences(),
options: options);
var diagnostics = compilation.GetDiagnostics();
if (diagnostics.Length > 0)

View File

@ -2,16 +2,14 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Reflection;
using System.Runtime.Versioning;
using Microsoft.AspNet.FileProviders;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using Microsoft.Dnx.Runtime;
using Microsoft.Extensions.CompilationAbstractions;
using Microsoft.Extensions.PlatformAbstractions;
using Microsoft.Extensions.OptionsModel;
using Microsoft.Extensions.PlatformAbstractions;
using Moq;
using Xunit;
@ -27,8 +25,8 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
// Arrange
var content = @"
public class MyTestType {}";
var applicationEnvironment = GetApplicationEnvironment();
var libraryExporter = GetLibraryExporter();
var applicationEnvironment = PlatformServices.Default.Application;
var libraryExporter = CompilationServices.Default.LibraryExporter;
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
compilerOptionsProvider
@ -67,8 +65,8 @@ public class MyTestType {}";
var content = $@"
#line 1 ""{viewPath}""
this should fail";
var applicationEnvironment = GetApplicationEnvironment();
var libraryExporter = GetLibraryExporter();
var applicationEnvironment = PlatformServices.Default.Application;
var libraryExporter = CompilationServices.Default.LibraryExporter;
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
compilerOptionsProvider
@ -106,8 +104,8 @@ this should fail";
// Arrange
var fileContent = "file content";
var content = @"this should fail";
var applicationEnvironment = GetApplicationEnvironment();
var libraryExporter = GetLibraryExporter();
var applicationEnvironment = PlatformServices.Default.Application;
var libraryExporter = CompilationServices.Default.LibraryExporter;
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
compilerOptionsProvider
@ -148,8 +146,8 @@ this should fail";
var content = $@"
#line 1 ""{path}""
this should fail";
var applicationEnvironment = GetApplicationEnvironment();
var libraryExporter = GetLibraryExporter();
var applicationEnvironment = PlatformServices.Default.Application;
var libraryExporter = CompilationServices.Default.LibraryExporter;
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
compilerOptionsProvider
@ -197,8 +195,8 @@ public class MyCustomDefinedClass {}
public class MyNonCustomDefinedClass {}
#endif
";
var applicationEnvironment = GetApplicationEnvironment();
var libraryExporter = GetLibraryExporter();
var applicationEnvironment = PlatformServices.Default.Application;
var libraryExporter = CompilationServices.Default.LibraryExporter;
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
compilerOptionsProvider
@ -236,8 +234,8 @@ public class MyNonCustomDefinedClass {}
var content = @"
public class RazorPrefixType {}
public class NotRazorPrefixType {}";
var applicationEnvironment = GetApplicationEnvironment();
var libraryExporter = GetLibraryExporter();
var applicationEnvironment = PlatformServices.Default.Application;
var libraryExporter = CompilationServices.Default.LibraryExporter;
var compilerOptionsProvider = new Mock<ICompilerOptionsProvider>();
compilerOptionsProvider
@ -284,8 +282,8 @@ public class NotRazorPrefixType {}";
FileProvider = fileProvider
});
var compilationService = new RoslynCompilationService(
GetApplicationEnvironment(),
GetLibraryExporter(),
PlatformServices.Default.Application,
CompilationServices.Default.LibraryExporter,
Mock.Of<ICompilerOptionsProvider>(),
Mock.Of<IMvcRazorHost>(),
options.Object);
@ -375,37 +373,6 @@ public class NotRazorPrefixType {}";
isEnabledByDefault: true);
}
private static ILibraryExporter GetLibraryExporter()
{
var fileReference = new Mock<IMetadataFileReference>();
fileReference
.SetupGet(f => f.Path)
.Returns(typeof(string).Assembly.Location);
var libraryExport = new LibraryExport(fileReference.Object);
var libraryExporter = new Mock<ILibraryExporter>();
libraryExporter
.Setup(l => l.GetAllExports(It.IsAny<string>()))
.Returns(libraryExport);
return libraryExporter.Object;
}
private IApplicationEnvironment GetApplicationEnvironment()
{
var applicationEnvironment = new Mock<IApplicationEnvironment>();
applicationEnvironment
.SetupGet(a => a.ApplicationName)
.Returns("MyApp");
applicationEnvironment
.SetupGet(a => a.RuntimeFramework)
.Returns(new FrameworkName("ASPNET", new Version(5, 0)));
applicationEnvironment
.SetupGet(a => a.ApplicationBasePath)
.Returns("MyBasePath");
return applicationEnvironment.Object;
}
private static IOptions<RazorViewEngineOptions> GetOptions(IFileProvider fileProvider = null)
{
var razorViewEngineOptions = new RazorViewEngineOptions
@ -421,4 +388,4 @@ public class NotRazorPrefixType {}";
return options.Object;
}
}
}
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc.Abstractions;
@ -74,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.Razor
serviceProvider.Setup(mock => mock.GetService(typeof(ITypeActivatorCache)))
.Returns(typeActivator);
serviceProvider.Setup(mock => mock.GetService(It.Is<Type>(serviceType =>
serviceType.IsGenericType && serviceType.GetGenericTypeDefinition() == typeof(IEnumerable<>))))
serviceType.GetTypeInfo().IsGenericType && serviceType.GetGenericTypeDefinition() == typeof(IEnumerable<>))))
.Returns<Type>(serviceType =>
{
var enumerableType = serviceType.GetGenericArguments().First();
@ -86,12 +87,13 @@ namespace Microsoft.AspNet.Mvc.Razor
var actionContext = new ActionContext(httpContext.Object, new RouteData(), new ActionDescriptor());
var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
var viewContext = new ViewContext(actionContext,
Mock.Of<IView>(),
viewData,
Mock.Of<ITempDataDictionary>(),
TextWriter.Null,
new HtmlHelperOptions());
var viewContext = new ViewContext(
actionContext,
Mock.Of<IView>(),
viewData,
Mock.Of<ITempDataDictionary>(),
TextWriter.Null,
new HtmlHelperOptions());
return new TestRazorPage
{

View File

@ -35,6 +35,11 @@
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
},
"exclude": [
@ -42,4 +47,4 @@
"node_modules",
"bower_components"
]
}
}

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Rendering;

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;

View File

@ -24,6 +24,11 @@
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
},
"exclude": [
@ -31,4 +36,4 @@
"node_modules",
"bower_components"
]
}
}

View File

@ -10,7 +10,6 @@ using Microsoft.AspNet.Mvc.ActionConstraints;
using Microsoft.AspNet.Mvc.ApiExplorer;
using Microsoft.AspNet.Mvc.ApplicationModels;
using Microsoft.AspNet.Mvc.Controllers;
using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.Cors;
using Microsoft.AspNet.Mvc.DataAnnotations.Internal;
using Microsoft.AspNet.Mvc.Filters;
@ -107,7 +106,7 @@ namespace Microsoft.AspNet.Mvc
// 'single-registration' services should only have one implementation registered.
AssertServiceCountEquals(services, service.ServiceType, 1);
}
else if (service.ImplementationType != null && !service.ImplementationType.Assembly.FullName.Contains("Mvc"))
else if (service.ImplementationType != null && !service.ImplementationType.GetTypeInfo().Assembly.FullName.Contains("Mvc"))
{
// Ignore types that don't come from MVC
}
@ -129,7 +128,7 @@ namespace Microsoft.AspNet.Mvc
var multiRegistrationServiceTypes = MutliRegistrationServiceTypes;
return services
.Where(sd => !multiRegistrationServiceTypes.Keys.Contains(sd.ServiceType))
.Where(sd => sd.ServiceType.Assembly.FullName.Contains("Mvc"))
.Where(sd => sd.ServiceType.GetTypeInfo().Assembly.FullName.Contains("Mvc"))
.Select(sd => sd.ServiceType);
}
}

View File

@ -13,9 +13,14 @@
},
"frameworks": {
"dnx451": {
"dependencies": {
"Moq": "4.2.1312.1622"
}
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": {
"dependencies": {
"moq.netcore": "4.4.0-beta8"
}
}
}
}
}

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
#if !FUNCTIONAL_TESTS
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;

View File

@ -5,7 +5,7 @@ using System;
namespace Microsoft.Extensions.Primitives
{
internal class TestFileChangeToken : IChangeToken
public class TestFileChangeToken : IChangeToken
{
public bool ActiveChangeCallbacks => false;

View File

@ -8,7 +8,7 @@ using Microsoft.AspNet.FileProviders;
namespace Microsoft.AspNet.Mvc.Razor
{
internal class TestFileInfo : IFileInfo
public class TestFileInfo : IFileInfo
{
private string _content;

View File

@ -9,7 +9,7 @@ using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNet.Mvc.Razor
{
internal class TestFileProvider : IFileProvider
public class TestFileProvider : IFileProvider
{
private readonly Dictionary<string, IFileInfo> _lookup =
new Dictionary<string, IFileInfo>(StringComparer.Ordinal);

View File

@ -5,8 +5,8 @@
"dnx451": {},
"dnxcore50": {
"dependencies": {
"System.Runtime": "4.0.21-*"
"System.Runtime": "4.0.21-*"
}
}
}
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.IO;
@ -1278,7 +1277,6 @@ namespace Microsoft.AspNet.Mvc.Test
// These tests share code with the ActionFilterAttribute tests because the various filter
// implementations need to behave the same way.
#if DNX451
[Fact]
public async Task Controller_ActionFilter_SettingResult_ShortCircuits()
{
@ -1640,8 +1638,6 @@ namespace Microsoft.AspNet.Mvc.Test
binder.Verify();
}
#endif
[Fact]
public void ControllerExposes_RequestServices()
{
@ -1969,5 +1965,3 @@ namespace Microsoft.AspNet.Mvc.Test
}
}
}
#endif

View File

@ -9,9 +9,7 @@ using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Controllers;
using Microsoft.AspNet.Routing;
#if MOCK_SUPPORT
using Moq;
#endif
using Newtonsoft.Json;
using Xunit;
@ -144,7 +142,6 @@ namespace Microsoft.AspNet.Mvc
}
}
#if MOCK_SUPPORT
[Fact]
public void ControllerFileStream_InvokedInUnitTests()
{
@ -180,7 +177,6 @@ namespace Microsoft.AspNet.Mvc
}
}
}
#endif
[Fact]
public void ControllerJson_InvokedInUnitTests()

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Diagnostics;
using System.Linq;
@ -212,4 +211,3 @@ namespace Microsoft.AspNet.Mvc
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http.Internal;
@ -666,4 +665,3 @@ namespace Microsoft.AspNet.Mvc
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -347,4 +346,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -692,4 +691,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Mvc.ModelBinding;
@ -229,4 +228,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using Microsoft.AspNet.Mvc.ModelBinding;
using Xunit;
@ -318,4 +317,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNet.Mvc.ViewFeatures;
@ -805,4 +804,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.IO;
@ -361,4 +360,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -902,4 +901,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Rendering;
@ -264,4 +263,3 @@ namespace Microsoft.AspNet.Mvc.Core
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Mvc.Routing;
@ -163,4 +162,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
@ -353,4 +352,3 @@ namespace Microsoft.AspNet.Mvc.Core
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Linq;
using System.Threading.Tasks;
@ -512,4 +511,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -400,4 +399,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -1711,4 +1710,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System.Collections.Generic;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Xunit;
@ -296,4 +295,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -411,4 +410,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Rendering;
@ -262,4 +261,3 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System.IO;
using System.Text;
using Microsoft.AspNet.Http.Internal;
@ -81,4 +80,3 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System.IO;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Abstractions;
@ -66,4 +65,3 @@ namespace Microsoft.AspNet.Mvc
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if DNX451
using System;
using System.IO;
using System.Threading.Tasks;
@ -64,4 +63,3 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.IO;
using System.Text;
@ -105,4 +104,3 @@ namespace Microsoft.AspNet.Mvc
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Diagnostics;
using System.IO;
@ -549,4 +548,3 @@ namespace Microsoft.AspNet.Mvc
}
}
}
#endif

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if MOCK_SUPPORT
using System;
using System.Linq;
using Microsoft.AspNet.Http;
@ -459,4 +458,3 @@ namespace Microsoft.AspNet.Mvc.ViewEngines
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More