From 017bf1a20fac90fc187056b1b5c031f463af37c2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 14 Oct 2015 15:13:25 -0700 Subject: [PATCH] Changes to use moq-netcore --- .../Internal/GlobbingUrlBuilder.cs | 3 +- .../HttpRequestMessageExtensions.cs | 5 +- .../project.json | 16 +++-- .../DefaultApiDescriptionProviderTest.cs | 3 +- .../project.json | 12 +++- .../ApplicationModel/ActionModelTest.cs | 2 +- .../AttributeRouteModelTests.cs | 5 +- .../ApplicationModel/ControllerModelTest.cs | 2 +- .../DefaultApplicationModelProviderTest.cs | 46 ++++++------- .../ApplicationModel/ParameterModelTest.cs | 4 +- .../ApplicationModel/PropertyModelTest.cs | 2 +- .../BindAttributeTest.cs | 4 -- .../ControllerActionArgumentBinderTests.cs | 2 +- .../ControllerActionDescriptorBuilderTest.cs | 6 +- .../ControllerActionInvokerTest.cs | 2 +- .../MvcBuilderExtensionsTest.cs | 6 +- .../FileResultTest.cs | 3 +- .../Filters/ActionFilterAttributeTests.cs | 2 - .../Formatters/FormatFilterTest.cs | 6 -- .../HttpResponseStreamWriterTest.cs | 22 ++++-- .../DefaultActionSelectorTests.cs | 22 +++--- .../ModelBinding/ArrayModelBinderTest.cs | 3 +- ...nderTypeBasedModelBinderModelBinderTest.cs | 2 - .../ModelBinding/CollectionModelBinderTest.cs | 10 +-- .../ModelBinding/CompositeModelBinderTest.cs | 2 - .../CompositeValueProviderTest.cs | 6 -- .../ModelBinding/DictionaryModelBinderTest.cs | 4 +- .../FormCollectionModelBinderTest.cs | 4 -- .../ModelBinding/FormFileModelBinderTest.cs | 4 -- .../KeyValuePairModelBinderTest.cs | 2 - .../Metadata/DefaultModelMetadataTest.cs | 4 -- .../ModelBinding/ModelBindingHelperTest.cs | 2 - .../MutableObjectModelBinderTest.cs | 2 - .../QueryStringValueProviderFactoryTest.cs | 9 +-- .../CompositeModelValidatorProviderTest.cs | 2 - .../Validation/DefaultObjectValidatorTests.cs | 5 +- .../NonDisposableStreamTest.cs | 7 +- .../ProducesAttributeTests.cs | 2 - .../Routing/AttributeRouteTest.cs | 2 - .../Routing/AttributeRoutingTest.cs | 5 +- .../Routing/KnownRouteValueConstraintTests.cs | 2 - .../project.json | 12 +++- .../project.json | 47 ++++++++----- ...taAnnotationsModelValidatorProviderTest.cs | 8 --- .../DataAnnotationsModelValidatorTest.cs | 69 ++++++++++--------- .../MaxLengthAttributeAdapterTest.cs | 4 +- .../TestResources.cs | 6 +- .../project.json | 47 ++++++++----- .../JsonInputFormatterTest.cs | 2 - .../JsonOutputFormatterTests.cs | 6 ++ .../project.json | 47 ++++++++----- ...ataContractSerializerInputFormatterTest.cs | 10 +-- ...taContractSerializerOutputFormatterTest.cs | 24 +++++++ .../project.json | 21 ++++-- .../project.json | 2 +- .../project.json | 50 +++++++------- .../project.json | 11 ++- .../MvcRazorHostTest.cs | 2 +- .../project.json | 7 +- .../Compilation/ExpressionRewriterTest.cs | 15 +++- .../RoslynCompilationServiceTest.cs | 65 +++++------------ .../RazorPageCreateTagHelperTest.cs | 16 +++-- .../project.json | 7 +- .../AnchorTagHelperTest.cs | 1 + .../FormTagHelperTest.cs | 1 + .../project.json | 7 +- .../MvcServiceCollectionExtensionsTest.cs | 5 +- test/Microsoft.AspNet.Mvc.Test/project.json | 13 ++-- .../CommonFilterTest.cs | 2 +- .../TestFileChangeToken.cs | 2 +- .../TestFileInfo.cs | 2 +- .../TestFileProvider.cs | 2 +- .../project.json | 4 +- .../project.json | 2 +- .../ControllerTest.cs | 6 -- .../ControllerUnitTestabilityTests.cs | 4 -- .../PartialViewResultTest.cs | 2 - .../RemoteAttributeTest.cs | 2 - .../Rendering/DefaultTemplatesUtilities.cs | 2 - .../Rendering/HtmlHelperCheckboxTest.cs | 2 - .../HtmlHelperDisplayNameExtensionsTest.cs | 2 - .../Rendering/HtmlHelperDisplayTextTest.cs | 2 - .../Rendering/HtmlHelperFormExtensionsTest.cs | 2 - .../Rendering/HtmlHelperFormTest.cs | 2 - .../Rendering/HtmlHelperHiddenTest.cs | 2 - .../HtmlHelperLabelExtensionsTest.cs | 2 - .../Rendering/HtmlHelperLinkGenerationTest.cs | 2 - .../Rendering/HtmlHelperNameExtensionsTest.cs | 2 - .../HtmlHelperPartialExtensionsTest.cs | 2 - .../Rendering/HtmlHelperPasswordTest.cs | 2 - .../Rendering/HtmlHelperSelectTest.cs | 2 - .../Rendering/HtmlHelperTest.cs | 2 - .../HtmlHelperValidationSummaryTest.cs | 2 - .../Rendering/HtmlHelperValueTest.cs | 2 - .../Rendering/ViewContextTests.cs | 2 - .../ContentViewComponentResultTest.cs | 2 - .../DefaultViewComponentActivatorTests.cs | 2 - .../JsonViewComponentResultTest.cs | 2 - .../ViewViewComponentResultTest.cs | 2 - .../ViewEngines/CompositeViewEngineTest.cs | 2 - .../DefaultDisplayTemplatesTest.cs | 2 - .../DefaultEditorTemplatesTest.cs | 2 - .../ViewFeatures/DefaultHtmlGeneratorTest.cs | 10 ++- .../PartialViewResultExecutorTest.cs | 2 - .../ViewFeatures/SaveTempDataFilterTest.cs | 2 - .../ViewFeatures/ViewDataDictionaryTest.cs | 11 ++- .../ViewFeatures/ViewExecutorTest.cs | 2 - .../ViewFeatures/ViewResultExecutorTest.cs | 2 - .../ViewResultTest.cs | 2 - .../project.json | 9 ++- .../ApiControllerActionDiscoveryTest.cs | 3 - .../BadRequestErrorMessageResultTest.cs | 2 - .../ExceptionResultTest.cs | 2 - .../HttpErrorTest.cs | 4 -- .../HttpRequestMessageExtensionsTest.cs | 9 ++- .../HttpResponseExceptionActionFilterTest.cs | 7 -- ...HttpResponseMessageOutputFormatterTests.cs | 33 ++++----- .../InvalidModelStateResultTest.cs | 2 - .../Mocks/MockMediaTypeMapping.cs | 1 + .../NegotiatedContentResultTest.cs | 2 - .../project.json | 8 ++- 121 files changed, 458 insertions(+), 490 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/GlobbingUrlBuilder.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/GlobbingUrlBuilder.cs index f58f21d73c..b2586c1332 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/GlobbingUrlBuilder.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/Internal/GlobbingUrlBuilder.cs @@ -27,8 +27,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal private readonly FileProviderGlobbingDirectory _baseGlobbingDirectory; - // Internal for testing - internal GlobbingUrlBuilder() { } + public GlobbingUrlBuilder() { } /// /// Creates a new . diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageExtensions.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageExtensions.cs index 69a421c8d7..1d0084f925 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageExtensions.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Mvc.Abstractions.Test/project.json b/test/Microsoft.AspNet.Mvc.Abstractions.Test/project.json index 24b10ab8ba..dfdd88998a 100644 --- a/test/Microsoft.AspNet.Mvc.Abstractions.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Abstractions.Test/project.json @@ -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" + } + } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/DefaultApiDescriptionProviderTest.cs b/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/DefaultApiDescriptionProviderTest.cs index 5c22fcc4eb..baf6da2b8c 100644 --- a/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/DefaultApiDescriptionProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/DefaultApiDescriptionProviderTest.cs @@ -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(); - foreach (var property in action.ControllerTypeInfo.GetProperties()) + foreach (var property in controllerType.GetProperties()) { var bindingInfo = BindingInfo.GetBindingInfo(property.GetCustomAttributes().OfType()); if (bindingInfo != null) diff --git a/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/project.json b/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/project.json index eeea81a7b5..eb2ec4abaa 100644 --- a/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.ApiExplorer.Test/project.json @@ -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" + } + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ActionModelTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ActionModelTest.cs index d115e507f9..0bfd840b3c 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ActionModelTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ActionModelTest.cs @@ -97,7 +97,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels // Ensure non-default value Assert.NotEmpty((IDictionary)value1); } - else if (property.PropertyType.IsValueType || + else if (property.PropertyType.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(property.PropertyType) != null) { Assert.Equal(value1, value2); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/AttributeRouteModelTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/AttributeRouteModelTests.cs index afabdbef0a..5cacca66b8 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/AttributeRouteModelTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/AttributeRouteModelTests.cs @@ -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).IsAssignableFrom(property.PropertyType)) + if (typeof(IEnumerable).GetTypeInfo().IsAssignableFrom(property.PropertyType.GetTypeInfo())) { Assert.Equal((IEnumerable)value1, (IEnumerable)value2); // Ensure non-default value Assert.NotEmpty((IEnumerable)value1); } - else if (property.PropertyType.IsValueType || + else if (property.PropertyType.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(property.PropertyType) != null) { Assert.Equal(value1, value2); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ControllerModelTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ControllerModelTest.cs index c9ba0ccb19..97b99d43c9 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ControllerModelTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ControllerModelTest.cs @@ -101,7 +101,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels // Ensure non-default value Assert.NotEmpty((IDictionary)value1); } - else if (property.PropertyType.IsValueType || + else if (property.PropertyType.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(property.PropertyType) != null) { Assert.Equal(value1, value2); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/DefaultApplicationModelProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/DefaultApplicationModelProviderTest.cs index 7a01301d08..2dc4f0a152 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/DefaultApplicationModelProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/DefaultApplicationModelProviderTest.cs @@ -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()); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ParameterModelTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ParameterModelTest.cs index e41583e814..0729d71815 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ParameterModelTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/ParameterModelTest.cs @@ -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)value1); } - else if (property.PropertyType.IsValueType || + else if (property.PropertyType.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(property.PropertyType) != null) { Assert.Equal(value1, value2); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/PropertyModelTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/PropertyModelTest.cs index 2f92115d57..b9b1e6c155 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/PropertyModelTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/PropertyModelTest.cs @@ -52,7 +52,7 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels // Ensure non-default value Assert.NotEmpty((IDictionary)value1); } - else if (property.PropertyType.IsValueType || + else if (property.PropertyType.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(property.PropertyType) != null) { Assert.Equal(value1, value2); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/BindAttributeTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/BindAttributeTest.cs index 14bfa0fd62..df9115a067 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/BindAttributeTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/BindAttributeTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionArgumentBinderTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionArgumentBinderTests.cs index 331a84dde2..ae7006762d 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionArgumentBinderTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionArgumentBinderTests.cs @@ -590,7 +590,7 @@ namespace Microsoft.AspNet.Mvc.Controllers Func method = foo => 1; return new ControllerActionDescriptor { - MethodInfo = method.Method, + MethodInfo = method.GetMethodInfo(), ControllerTypeInfo = typeof(TestController).GetTypeInfo(), BoundProperties = new List(), Parameters = new List() diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionDescriptorBuilderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionDescriptorBuilderTest.cs index 19723c22e5..9bb0d64991 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionDescriptorBuilderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionDescriptorBuilderTest.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.Controllers typeof(TestController).GetTypeInfo(), new List() { }); - 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() { })); + new PropertyModel( + controller.ControllerType.AsType().GetProperty("UnboundProperty"), + new List() { })); controller.Application = applicationModel; applicationModel.Controllers.Add(controller); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionInvokerTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionInvokerTest.cs index 6722ac4266..91b3db1159 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionInvokerTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Controllers/ControllerActionInvokerTest.cs @@ -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!" }; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/DependencyInjection/MvcBuilderExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/DependencyInjection/MvcBuilderExtensionsTest.cs index 3940703877..ff864d87d8 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/DependencyInjection/MvcBuilderExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/DependencyInjection/MvcBuilderExtensionsTest.cs @@ -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(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); } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/FileResultTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/FileResultTest.cs index 2951a83a19..75f9c4214c 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/FileResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/FileResultTest.cs @@ -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")) { } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Filters/ActionFilterAttributeTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Filters/ActionFilterAttributeTests.cs index 6aa6384e52..42dadaa6d1 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Filters/ActionFilterAttributeTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Filters/ActionFilterAttributeTests.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Formatters/FormatFilterTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Formatters/FormatFilterTest.cs index 60a6f22a4e..d4fd11e176 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Formatters/FormatFilterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Formatters/FormatFilterTest.cs @@ -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 } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/HttpResponseStreamWriterTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/HttpResponseStreamWriterTest.cs index 4918426050..e2ad414991 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/HttpResponseStreamWriterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/HttpResponseStreamWriterTest.cs @@ -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) { diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Infrastructure/DefaultActionSelectorTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Infrastructure/DefaultActionSelectorTests.cs index 81b7b4af82..c1b3c74de4 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Infrastructure/DefaultActionSelectorTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Infrastructure/DefaultActionSelectorTests.cs @@ -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() { actionDescriptorProvider, }; - serviceContainer.AddService(typeof(IEnumerable), list); + serviceContainer.AddSingleton(typeof(IEnumerable), 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(MockBehavior.Strict).Object); - var serviceContainer = new ServiceContainer(); + var serviceProvider = new ServiceCollection().BuildServiceProvider(); var httpContext = new Mock(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) { diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ArrayModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ArrayModelBinderTest.cs index 298b58c22d..84b00edd44 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ArrayModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ArrayModelBinderTest.cs @@ -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 + diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/BinderTypeBasedModelBinderModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/BinderTypeBasedModelBinderModelBinderTest.cs index 19199a40b9..ca07cf5c47 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/BinderTypeBasedModelBinderModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/BinderTypeBasedModelBinderModelBinderTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CollectionModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CollectionModelBinderTest.cs index 63667cebc9..6a47587906 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CollectionModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CollectionModelBinderTest.cs @@ -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>(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."); } } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeModelBinderTest.cs index 03f4812424..34759ccf48 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeModelBinderTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs index 299bc0cdc0..34ae4bf727 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/CompositeValueProviderTest.cs @@ -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 } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs index af1b26eeed..8424e4265a 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/DictionaryModelBinderTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs index d1a898607f..6f6bb197b6 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormCollectionModelBinderTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormFileModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormFileModelBinderTest.cs index e10090316f..972c24af9b 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormFileModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/FormFileModelBinderTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/KeyValuePairModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/KeyValuePairModelBinderTest.cs index 6e9bb26110..2d95a3ea6d 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/KeyValuePairModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/KeyValuePairModelBinderTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Metadata/DefaultModelMetadataTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Metadata/DefaultModelMetadataTest.cs index 720fbdc2d2..e3c043c894 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Metadata/DefaultModelMetadataTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Metadata/DefaultModelMetadataTest.cs @@ -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() diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ModelBindingHelperTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ModelBindingHelperTest.cs index 887ad4a051..b6aca0985b 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ModelBindingHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ModelBindingHelperTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/MutableObjectModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/MutableObjectModelBinderTest.cs index 4693040d04..e5915c720c 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/MutableObjectModelBinderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/MutableObjectModelBinderTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/QueryStringValueProviderFactoryTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/QueryStringValueProviderFactoryTest.cs index a13aa7bb5c..721a4ca869 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/QueryStringValueProviderFactoryTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/QueryStringValueProviderFactoryTest.cs @@ -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()); 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(result); Assert.Equal(CultureInfo.InvariantCulture, valueProvider.Culture); } -#endif } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/CompositeModelValidatorProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/CompositeModelValidatorProviderTest.cs index 53d4adb370..0a35f16c56 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/CompositeModelValidatorProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/CompositeModelValidatorProviderTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs index 739159583b..ec70897c61 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/NonDisposableStreamTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/NonDisposableStreamTest.cs index c1acf56566..4602ce65df 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/NonDisposableStreamTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/NonDisposableStreamTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ProducesAttributeTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ProducesAttributeTests.cs index 7d27a6ac7c..8f0834da7c 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ProducesAttributeTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ProducesAttributeTests.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs index d773225009..b128423581 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRouteTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs index 39e2e43e59..1216795d80 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/AttributeRoutingTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs index d15c6a138b..8a7a7600bc 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Routing/KnownRouteValueConstraintTests.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/project.json b/test/Microsoft.AspNet.Mvc.Core.Test/project.json index 35480779e8..288913cae2 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Core.Test/project.json @@ -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" + } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Cors.Test/project.json b/test/Microsoft.AspNet.Mvc.Cors.Test/project.json index 3e0984d906..98bc72dec5 100644 --- a/test/Microsoft.AspNet.Mvc.Cors.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Cors.Test/project.json @@ -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" + } } -} + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/DataAnnotationsModelValidatorProviderTest.cs b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/DataAnnotationsModelValidatorProviderTest.cs index eb9982a2ff..92e91e9cbe 100644 --- a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/DataAnnotationsModelValidatorProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/DataAnnotationsModelValidatorProviderTest.cs @@ -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(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 { diff --git a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/DataAnnotationsModelValidatorTest.cs b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/DataAnnotationsModelValidatorTest.cs index 46cfa16039..4200b50029 100644 --- a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/DataAnnotationsModelValidatorTest.cs +++ b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/DataAnnotationsModelValidatorTest.cs @@ -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 { CallBase = true }; - attribute.Protected() - .Setup("IsValid", ItExpr.IsAny(), ItExpr.IsAny()) - .Callback((object o, ValidationContext context) => - { - Assert.Equal(expectedMemberName, context.MemberName); - }) - .Returns(ValidationResult.Success) - .Verifiable(); + var attribute = new Mock { CallBase = true }; + attribute + .Setup(p => p.IsValidPublic(It.IsAny(), It.IsAny())) + .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 { CallBase = true }; - attribute.Protected() - .Setup("IsValid", ItExpr.IsAny(), ItExpr.IsAny()) - .Returns(ValidationResult.Success); + var attribute = new Mock { CallBase = true }; + attribute + .Setup(p => p.IsValidPublic(It.IsAny(), It.IsAny())) + .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 { CallBase = true }; - attribute.Protected() - .Setup("IsValid", ItExpr.IsAny(), ItExpr.IsAny()) - .Returns(new ValidationResult(errorMessage, memberNames: null)); + var attribute = new Mock { CallBase = true }; + attribute + .Setup(p => p.IsValidPublic(It.IsAny(), It.IsAny())) + .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 { CallBase = true }; - attribute.Protected() - .Setup("IsValid", ItExpr.IsAny(), ItExpr.IsAny()) - .Returns(new ValidationResult(errorMessage, new[] { "FirstName" })); + var attribute = new Mock { CallBase = true }; + attribute + .Setup(p => p.IsValidPublic(It.IsAny(), It.IsAny())) + .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 { CallBase = true }; - attribute.Protected() - .Setup("IsValid", ItExpr.IsAny(), ItExpr.IsAny()) - .Returns(new ValidationResult("Name error", new[] { "Name" })); + var attribute = new Mock { CallBase = true }; + attribute + .Setup(p => p.IsValidPublic(It.IsAny(), It.IsAny())) + .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; } diff --git a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/MaxLengthAttributeAdapterTest.cs b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/MaxLengthAttributeAdapterTest.cs index 85f3d73392..190f2d34ba 100644 --- a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/MaxLengthAttributeAdapterTest.cs +++ b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/MaxLengthAttributeAdapterTest.cs @@ -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 - } + } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/TestResources.cs b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/TestResources.cs index 6675c715da..436be803e0 100644 --- a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/TestResources.cs +++ b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/TestResources.cs @@ -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; } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/project.json b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/project.json index 2fc432a50e..d472ab179b 100644 --- a/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.DataAnnotations.Test/project.json @@ -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" + } } -} + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/JsonInputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/JsonInputFormatterTest.cs index 155446b16e..7107b8791a 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/JsonInputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/JsonInputFormatterTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/JsonOutputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/JsonOutputFormatterTests.cs index d5fc0b8c76..bdcf9d9884 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/JsonOutputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/JsonOutputFormatterTests.cs @@ -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; } diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/project.json b/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/project.json index 65487e6f12..98bc72dec5 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Formatters.Json.Test/project.json @@ -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" + } } -} + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs index 061c58f7b4..9bf70ab092 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs index 09eb667e90..7bcf82d570 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs @@ -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 = @"1Test"; + 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 diff --git a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json index 77435faa82..7d168a0ca7 100644 --- a/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json @@ -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" + } + } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json b/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json index db61c58fc3..476efc77d8 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/project.json @@ -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": { diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/project.json b/test/Microsoft.AspNet.Mvc.IntegrationTests/project.json index dc4ccfa792..31780f76f0 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/project.json +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/project.json @@ -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" + } } -} + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Localization.Test/project.json b/test/Microsoft.AspNet.Mvc.Localization.Test/project.json index 8d766088cd..082dc335a9 100644 --- a/test/Microsoft.AspNet.Mvc.Localization.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Localization.Test/project.json @@ -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" + } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs index ec111a4d74..e3d963a49b 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs @@ -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 { diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/project.json b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/project.json index f66330c645..18e6381b9d 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/project.json @@ -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" ] -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/ExpressionRewriterTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/ExpressionRewriterTest.cs index e210c04c03..a1eac9a7c2 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/ExpressionRewriterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/ExpressionRewriterTest.cs @@ -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 + { + { "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) diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RoslynCompilationServiceTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RoslynCompilationServiceTest.cs index 799bc4d594..66c0647927 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RoslynCompilationServiceTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/RoslynCompilationServiceTest.cs @@ -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(); 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(); 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(); 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(); 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(); 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(); compilerOptionsProvider @@ -284,8 +282,8 @@ public class NotRazorPrefixType {}"; FileProvider = fileProvider }); var compilationService = new RoslynCompilationService( - GetApplicationEnvironment(), - GetLibraryExporter(), + PlatformServices.Default.Application, + CompilationServices.Default.LibraryExporter, Mock.Of(), Mock.Of(), options.Object); @@ -375,37 +373,6 @@ public class NotRazorPrefixType {}"; isEnabledByDefault: true); } - private static ILibraryExporter GetLibraryExporter() - { - var fileReference = new Mock(); - fileReference - .SetupGet(f => f.Path) - .Returns(typeof(string).Assembly.Location); - var libraryExport = new LibraryExport(fileReference.Object); - - var libraryExporter = new Mock(); - libraryExporter - .Setup(l => l.GetAllExports(It.IsAny())) - .Returns(libraryExport); - return libraryExporter.Object; - } - - private IApplicationEnvironment GetApplicationEnvironment() - { - var applicationEnvironment = new Mock(); - 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 GetOptions(IFileProvider fileProvider = null) { var razorViewEngineOptions = new RazorViewEngineOptions @@ -421,4 +388,4 @@ public class NotRazorPrefixType {}"; return options.Object; } } -} \ No newline at end of file +} diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageCreateTagHelperTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageCreateTagHelperTest.cs index 0d5b437f7b..5a9ea38ad7 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageCreateTagHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageCreateTagHelperTest.cs @@ -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(serviceType => - serviceType.IsGenericType && serviceType.GetGenericTypeDefinition() == typeof(IEnumerable<>)))) + serviceType.GetTypeInfo().IsGenericType && serviceType.GetGenericTypeDefinition() == typeof(IEnumerable<>)))) .Returns(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(), - viewData, - Mock.Of(), - TextWriter.Null, - new HtmlHelperOptions()); + var viewContext = new ViewContext( + actionContext, + Mock.Of(), + viewData, + Mock.Of(), + TextWriter.Null, + new HtmlHelperOptions()); return new TestRazorPage { diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/project.json b/test/Microsoft.AspNet.Mvc.Razor.Test/project.json index 4221110f7f..1ccadd6f5b 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/project.json @@ -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" ] -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/AnchorTagHelperTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/AnchorTagHelperTest.cs index 98d37d5546..09ca712dd2 100644 --- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/AnchorTagHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/AnchorTagHelperTest.cs @@ -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; diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/FormTagHelperTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/FormTagHelperTest.cs index 99b35c55af..f7dd1b0768 100644 --- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/FormTagHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/FormTagHelperTest.cs @@ -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; diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/project.json b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/project.json index b07eed16a4..2b2b91e807 100644 --- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/project.json @@ -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" ] -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Test/MvcServiceCollectionExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.Test/MvcServiceCollectionExtensionsTest.cs index bd177e1d65..1f0df95c97 100644 --- a/test/Microsoft.AspNet.Mvc.Test/MvcServiceCollectionExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.Test/MvcServiceCollectionExtensionsTest.cs @@ -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); } } diff --git a/test/Microsoft.AspNet.Mvc.Test/project.json b/test/Microsoft.AspNet.Mvc.Test/project.json index f808622933..0a69662e54 100644 --- a/test/Microsoft.AspNet.Mvc.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.Test/project.json @@ -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" + } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/CommonFilterTest.cs b/test/Microsoft.AspNet.Mvc.TestCommon/CommonFilterTest.cs index 914735368e..ad61a9d68f 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/CommonFilterTest.cs +++ b/test/Microsoft.AspNet.Mvc.TestCommon/CommonFilterTest.cs @@ -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; diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/TestFileChangeToken.cs b/test/Microsoft.AspNet.Mvc.TestCommon/TestFileChangeToken.cs index d7b2cc22ee..718e089e2b 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/TestFileChangeToken.cs +++ b/test/Microsoft.AspNet.Mvc.TestCommon/TestFileChangeToken.cs @@ -5,7 +5,7 @@ using System; namespace Microsoft.Extensions.Primitives { - internal class TestFileChangeToken : IChangeToken + public class TestFileChangeToken : IChangeToken { public bool ActiveChangeCallbacks => false; diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/TestFileInfo.cs b/test/Microsoft.AspNet.Mvc.TestCommon/TestFileInfo.cs index 7d66e72bcf..68af81d4b9 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/TestFileInfo.cs +++ b/test/Microsoft.AspNet.Mvc.TestCommon/TestFileInfo.cs @@ -8,7 +8,7 @@ using Microsoft.AspNet.FileProviders; namespace Microsoft.AspNet.Mvc.Razor { - internal class TestFileInfo : IFileInfo + public class TestFileInfo : IFileInfo { private string _content; diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/TestFileProvider.cs b/test/Microsoft.AspNet.Mvc.TestCommon/TestFileProvider.cs index fda5881d4b..dde6a65e5b 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/TestFileProvider.cs +++ b/test/Microsoft.AspNet.Mvc.TestCommon/TestFileProvider.cs @@ -9,7 +9,7 @@ using Microsoft.Extensions.Primitives; namespace Microsoft.AspNet.Mvc.Razor { - internal class TestFileProvider : IFileProvider + public class TestFileProvider : IFileProvider { private readonly Dictionary _lookup = new Dictionary(StringComparer.Ordinal); diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/project.json b/test/Microsoft.AspNet.Mvc.TestCommon/project.json index d763a710c3..6218f84671 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/project.json +++ b/test/Microsoft.AspNet.Mvc.TestCommon/project.json @@ -5,8 +5,8 @@ "dnx451": {}, "dnxcore50": { "dependencies": { - "System.Runtime": "4.0.21-*" + "System.Runtime": "4.0.21-*" } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources/project.json b/test/Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources/project.json index 3e473054c8..548839c173 100644 --- a/test/Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources/project.json +++ b/test/Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources/project.json @@ -9,4 +9,4 @@ } } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerTest.cs index 754958d94d..c6ec89c2d2 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerUnitTestabilityTests.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerUnitTestabilityTests.cs index d2ea0b1605..e64188ec44 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerUnitTestabilityTests.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ControllerUnitTestabilityTests.cs @@ -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() diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/PartialViewResultTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/PartialViewResultTest.cs index 523fab47e4..255d734587 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/PartialViewResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/PartialViewResultTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/RemoteAttributeTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/RemoteAttributeTest.cs index c383a6a3fb..cdcab8708d 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/RemoteAttributeTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/RemoteAttributeTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/DefaultTemplatesUtilities.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/DefaultTemplatesUtilities.cs index 57a8da43d5..27f80ea158 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/DefaultTemplatesUtilities.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/DefaultTemplatesUtilities.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperCheckboxTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperCheckboxTest.cs index 5d63afbee3..f8e140617c 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperCheckboxTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperCheckboxTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayNameExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayNameExtensionsTest.cs index 0e48a7cced..517d3af000 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayNameExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayNameExtensionsTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayTextTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayTextTest.cs index ec1d2d954f..a74c7aebed 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayTextTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayTextTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormExtensionsTest.cs index 243aeb9c6d..42cb56b97b 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormExtensionsTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormTest.cs index a1628c06b6..de4577ee68 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperFormTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperHiddenTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperHiddenTest.cs index ecbaf21235..abf284d263 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperHiddenTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperHiddenTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperLabelExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperLabelExtensionsTest.cs index 4a89eb8a41..b699936368 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperLabelExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperLabelExtensionsTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperLinkGenerationTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperLinkGenerationTest.cs index 9418a5af20..77e2c9cf8c 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperLinkGenerationTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperLinkGenerationTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperNameExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperNameExtensionsTest.cs index 160905d1b8..03a1dc877b 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperNameExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperNameExtensionsTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPartialExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPartialExtensionsTest.cs index 31577cd84a..ec485e2a0f 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPartialExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPartialExtensionsTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPasswordTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPasswordTest.cs index 6b3472d2fb..03f564207e 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPasswordTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPasswordTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs index 5f3cf9f91a..29f2f34ea4 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperTest.cs index 9861c117eb..b388ce93d9 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperTest.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValidationSummaryTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValidationSummaryTest.cs index 325bf1914a..30b01305d2 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValidationSummaryTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValidationSummaryTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValueTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValueTest.cs index 4f8ba5196a..f6f3310ad4 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValueTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValueTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/ViewContextTests.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/ViewContextTests.cs index 509c819a2d..bbe296f5d5 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/ViewContextTests.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/ViewContextTests.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/ContentViewComponentResultTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/ContentViewComponentResultTest.cs index ee447c033d..0ee7662aad 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/ContentViewComponentResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/ContentViewComponentResultTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/DefaultViewComponentActivatorTests.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/DefaultViewComponentActivatorTests.cs index 60dcf2f7e4..0762717b61 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/DefaultViewComponentActivatorTests.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/DefaultViewComponentActivatorTests.cs @@ -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 diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/JsonViewComponentResultTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/JsonViewComponentResultTest.cs index 904cc757cd..7b8b90f918 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/JsonViewComponentResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/JsonViewComponentResultTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/ViewViewComponentResultTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/ViewViewComponentResultTest.cs index 2ca3123db3..95e4603207 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/ViewViewComponentResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewComponents/ViewViewComponentResultTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewEngines/CompositeViewEngineTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewEngines/CompositeViewEngineTest.cs index 5c62577f14..279bce1e95 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewEngines/CompositeViewEngineTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewEngines/CompositeViewEngineTest.cs @@ -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 \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultDisplayTemplatesTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultDisplayTemplatesTest.cs index 6bddfe9518..d8034d19a6 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultDisplayTemplatesTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultDisplayTemplatesTest.cs @@ -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.ViewFeatures } } } -#endif \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultEditorTemplatesTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultEditorTemplatesTest.cs index c3e3e263b0..02e281bda7 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultEditorTemplatesTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultEditorTemplatesTest.cs @@ -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; @@ -1212,4 +1211,3 @@ Environment.NewLine; } } } -#endif \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultHtmlGeneratorTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultHtmlGeneratorTest.cs index 35aefb46ae..95c4935bbe 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultHtmlGeneratorTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/DefaultHtmlGeneratorTest.cs @@ -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; @@ -74,8 +73,8 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures var viewContext = GetViewContext(model: null, metadataProvider: metadataProvider); var modelExplorer = metadataProvider.GetModelExplorerForType(typeof(string), model: null); - var expected = "The name of an HTML field cannot be null or empty. Instead use methods " + - "Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.Editor or Microsoft.AspNet.Mvc.Rendering." + + var expected = "The name of an HTML field cannot be null or empty. Instead use methods " + + "Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.Editor or Microsoft.AspNet.Mvc.Rendering." + "IHtmlHelper`1.EditorFor with a non-empty htmlFieldName argument value." + Environment.NewLine + "Parameter name: expression"; @@ -136,7 +135,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures // Act and assert var ex = Assert.Throws( - "expression", + "expression", () => htmlGenerator.GenerateTextArea( viewContext, modelExplorer, @@ -164,7 +163,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures // Act and assert var ex = Assert.Throws( - "expression", + "expression", () => htmlGenerator.GenerateValidationMessage( viewContext, null, @@ -713,4 +712,3 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures } } } -#endif \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/PartialViewResultExecutorTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/PartialViewResultExecutorTest.cs index 88a91b2c3c..f583d3afe6 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/PartialViewResultExecutorTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/PartialViewResultExecutorTest.cs @@ -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.Diagnostics; using System.Linq; using System.Threading.Tasks; @@ -345,4 +344,3 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures } } } -#endif diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/SaveTempDataFilterTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/SaveTempDataFilterTest.cs index 94f98f0f03..47619fbc45 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/SaveTempDataFilterTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/SaveTempDataFilterTest.cs @@ -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.Http.Internal; using Microsoft.AspNet.Mvc.Abstractions; using Microsoft.AspNet.Mvc.Filters; @@ -79,4 +78,3 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures } } } -#endif \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryTest.cs index 41cf274ee8..d449c84a1c 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryTest.cs @@ -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; using System.Collections.Generic; @@ -682,7 +681,14 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures { // Arrange var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider()); - viewData.Add("Foo", new Dictionary { { "Bar", new Hashtable { { "Baz", "Quux" } } } }); + var value = new Dictionary + { + ["Bar"] = new Dictionary + { + { "Baz", "Quux" } + } + }; + viewData.Add("Foo", value); // Act var result = viewData.Eval("Foo.Bar.Baz"); @@ -819,4 +825,3 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures } } } -#endif \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewExecutorTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewExecutorTest.cs index 88583845df..6c09649226 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewExecutorTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewExecutorTest.cs @@ -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; @@ -362,4 +361,3 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures } } } -#endif \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewResultExecutorTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewResultExecutorTest.cs index eaac43241d..6a1b5842ae 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewResultExecutorTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewFeatures/ViewResultExecutorTest.cs @@ -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.Diagnostics; using System.Linq; using System.Threading.Tasks; @@ -341,4 +340,3 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures } } } -#endif diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewResultTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewResultTest.cs index b950f5f335..50aa88f9ab 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ViewResultTest.cs @@ -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; @@ -211,4 +210,3 @@ namespace Microsoft.AspNet.Mvc } } } -#endif \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json index 76da26f0a3..288913cae2 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json @@ -26,11 +26,14 @@ }, "frameworks": { "dnx451": { - "compilationOptions": { "define": [ "MOCK_SUPPORT" ] }, "dependencies": { "Moq": "4.2.1312.1622" } }, - "dnxcore50": { } + "dnxcore50": { + "dependencies": { + "moq.netcore": "4.4.0-beta8" + } + } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs index b89dc43cef..f4c44b53a2 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ApiControllerActionDiscoveryTest.cs @@ -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 !DNXCORE50 - using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -508,4 +506,3 @@ namespace System.Web.Http.TestControllers } } } -#endif diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/BadRequestErrorMessageResultTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/BadRequestErrorMessageResultTest.cs index 5627ce7e70..ba82333d56 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/BadRequestErrorMessageResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/BadRequestErrorMessageResultTest.cs @@ -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.IO; using System.Threading.Tasks; using Microsoft.AspNet.Http; @@ -83,4 +82,3 @@ namespace System.Web.Http } } } -#endif diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ExceptionResultTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ExceptionResultTest.cs index 479a3bf215..d1bdc3d77b 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ExceptionResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/ExceptionResultTest.cs @@ -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.IO; using System.Threading.Tasks; using Microsoft.AspNet.Http; @@ -81,4 +80,3 @@ namespace System.Web.Http } } } -#endif diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs index de1acc77a4..7f006c1a66 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs @@ -127,8 +127,6 @@ namespace System.Web.Http.Dispatcher Assert.DoesNotContain("OH NO", modelStateError["[2].Name"] as IEnumerable); } -#if !DNXCORE50 - [Fact] public void HttpError_Roundtrips_WithJsonFormatter() { @@ -219,8 +217,6 @@ namespace System.Web.Http.Dispatcher serializedError); } -#endif - [Fact] public void GetPropertyValue_GetsValue_IfTypeMatches() { diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageExtensionsTest.cs index 5ceea22157..fa0b3ad225 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageExtensionsTest.cs @@ -9,9 +9,7 @@ using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.WebApiCompatShim; using Microsoft.AspNet.Testing; using Microsoft.Extensions.OptionsModel; -#if !DNXCORE50 using Moq; -#endif using Xunit; namespace System.Net.Http @@ -50,8 +48,6 @@ namespace System.Net.Http ex.Message); } -#if !DNXCORE50 - [Fact] public void CreateResponse_DoingConneg_OnlyContent_RetrievesContentNegotiatorFromServices() { @@ -286,6 +282,8 @@ namespace System.Net.Http Assert.Equal("bin/baz", response.Content.Headers.ContentType.MediaType); } +#if !DNXCORE50 + // API doesn't exist in CoreCLR. [Fact] public void CreateErrorResponseRangeNotSatisfiable_SetsCorrectStatusCodeAndContentRangeHeader() { @@ -305,6 +303,7 @@ namespace System.Net.Http Assert.Equal(HttpStatusCode.RequestedRangeNotSatisfiable, response.StatusCode); Assert.Same(expectedContentRange, response.Content.Headers.ContentRange); } +#endif private static IServiceProvider CreateServices( IContentNegotiator contentNegotiator = null, @@ -338,7 +337,7 @@ namespace System.Net.Http return services.Object; } -#endif + private static object CreateValue() { return new object(); diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseExceptionActionFilterTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseExceptionActionFilterTest.cs index 26e357ea4f..acead1c524 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseExceptionActionFilterTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseExceptionActionFilterTest.cs @@ -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 !DNXCORE50 using System.Collections.Generic; using System.Net; using System.Net.Http; @@ -11,7 +10,6 @@ using Microsoft.AspNet.Mvc.Abstractions; using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Routing; using Moq; -#endif using Xunit; namespace Microsoft.AspNet.Mvc.WebApiCompatShim @@ -29,8 +27,6 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim Assert.Equal(expectedFilterOrder, filter.Order); } -#if !DNXCORE50 - [Fact] public void OnActionExecuting_IsNoOp() { @@ -87,8 +83,5 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim Assert.Equal(context.HttpContext.GetHttpRequestMessage(), response.RequestMessage); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); } - -#endif - } } diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs index ede1a793ad..170bea7ebd 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs @@ -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 !DNXCORE50 - using System; using System.IO; using System.Net.Http; @@ -31,9 +29,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest var httpResponseMessage = new HttpResponseMessage(); httpResponseMessage.Content = streamContent.Object; var outputFormatterContext = GetOutputFormatterContext( - httpResponseMessage, - typeof(HttpResponseMessage), - new DefaultHttpContext()); + httpResponseMessage, + typeof(HttpResponseMessage), + new DefaultHttpContext()); // Act await formatter.WriteAsync(outputFormatterContext); @@ -55,9 +53,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest var httpContext = new DefaultHttpContext(); var formatter = new HttpResponseMessageOutputFormatter(); var outputFormatterContext = GetOutputFormatterContext( - httpResponseMessage, - typeof(HttpResponseMessage), - httpContext); + httpResponseMessage, + typeof(HttpResponseMessage), + httpContext); // Act await formatter.WriteAsync(outputFormatterContext); @@ -80,9 +78,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest var httpContext = new DefaultHttpContext(); var formatter = new HttpResponseMessageOutputFormatter(); var outputFormatterContext = GetOutputFormatterContext( - httpResponseMessage, - typeof(HttpResponseMessage), - httpContext); + httpResponseMessage, + typeof(HttpResponseMessage), + httpContext); // Act await formatter.WriteAsync(outputFormatterContext); @@ -105,9 +103,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest var httpContext = new DefaultHttpContext(); var formatter = new HttpResponseMessageOutputFormatter(); var outputFormatterContext = GetOutputFormatterContext( - httpResponseMessage, - typeof(HttpResponseMessage), - httpContext); + httpResponseMessage, + typeof(HttpResponseMessage), + httpContext); // Act await formatter.WriteAsync(outputFormatterContext); @@ -133,9 +131,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest var httpContext = new DefaultHttpContext(); var formatter = new HttpResponseMessageOutputFormatter(); var outputFormatterContext = GetOutputFormatterContext( - httpResponseMessage, - typeof(HttpResponseMessage), - httpContext); + httpResponseMessage, + typeof(HttpResponseMessage), + httpContext); // Act await formatter.WriteAsync(outputFormatterContext); @@ -159,4 +157,3 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest } } } -#endif diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/InvalidModelStateResultTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/InvalidModelStateResultTest.cs index 24ff0a3801..fc92b34e35 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/InvalidModelStateResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/InvalidModelStateResultTest.cs @@ -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.IO; using System.Threading.Tasks; using Microsoft.AspNet.Http; @@ -94,4 +93,3 @@ namespace System.Web.Http } } } -#endif diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/Mocks/MockMediaTypeMapping.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/Mocks/MockMediaTypeMapping.cs index 52313de781..820028afb0 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/Mocks/MockMediaTypeMapping.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/Mocks/MockMediaTypeMapping.cs @@ -4,6 +4,7 @@ #if !DNXCORE50 using System.Net.Http.Headers; + namespace System.Net.Http.Formatting.Mocks { public class MockMediaTypeMapping : MediaTypeMapping diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/NegotiatedContentResultTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/NegotiatedContentResultTest.cs index 622c220a71..41dec85ad6 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/NegotiatedContentResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/NegotiatedContentResultTest.cs @@ -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.IO; using System.Net; using System.Threading.Tasks; @@ -88,4 +87,3 @@ namespace System.Web.Http }; } } -#endif diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/project.json b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/project.json index 8799b5ed65..72872a4bd3 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/project.json +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/project.json @@ -19,6 +19,10 @@ "Moq": "4.2.1312.1622" } }, - "dnxcore50": { } + "dnxcore50": { + "dependencies": { + "moq.netcore": "4.4.0-beta8" + } + } } -} +} \ No newline at end of file