Renable compatibility switch functional tests

This commit is contained in:
Ryan Nowak 2018-01-07 22:13:03 -08:00
parent 58026eacbd
commit 95d743e2c6
1 changed files with 12 additions and 5 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Mvc.Formatters; using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.ObjectPool; using Microsoft.Extensions.ObjectPool;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -16,7 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTest
// here should include verification for all of the switches. // here should include verification for all of the switches.
public class CompatibilitySwitchIntegrationTest public class CompatibilitySwitchIntegrationTest
{ {
[Fact(Skip = "#7157 - some settings have the wrong values, this test should pass once #7157 is fixed")] [Fact]
public void CompatibilitySwitches_Version_2_0() public void CompatibilitySwitches_Version_2_0()
{ {
// Arrange // Arrange
@ -29,51 +30,57 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTest
// Act // Act
var mvcOptions = services.GetRequiredService<IOptions<MvcOptions>>().Value; var mvcOptions = services.GetRequiredService<IOptions<MvcOptions>>().Value;
var jsonOptions = services.GetRequiredService<IOptions<MvcJsonOptions>>().Value; var jsonOptions = services.GetRequiredService<IOptions<MvcJsonOptions>>().Value;
var razorPagesOptions = services.GetRequiredService<IOptions<RazorPagesOptions>>().Value;
// Assert // Assert
Assert.False(mvcOptions.SuppressBindingUndefinedValueToEnumType); Assert.False(mvcOptions.SuppressBindingUndefinedValueToEnumType);
Assert.Equal(InputFormatterExceptionPolicy.AllExceptions, mvcOptions.InputFormatterExceptionPolicy); Assert.Equal(InputFormatterExceptionPolicy.AllExceptions, mvcOptions.InputFormatterExceptionPolicy);
Assert.False(jsonOptions.AllowInputFormatterExceptionMessages); Assert.False(jsonOptions.AllowInputFormatterExceptionMessages);
Assert.False(razorPagesOptions.AllowAreas);
} }
[Fact(Skip = "#7157 - some settings have the wrong values, this test should pass once #7157 is fixed")] [Fact]
public void CompatibilitySwitches_Version_2_1() public void CompatibilitySwitches_Version_2_1()
{ {
// Arrange // Arrange
var serviceCollection = new ServiceCollection(); var serviceCollection = new ServiceCollection();
AddHostingServices(serviceCollection); AddHostingServices(serviceCollection);
serviceCollection.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_0); serviceCollection.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
var services = serviceCollection.BuildServiceProvider(); var services = serviceCollection.BuildServiceProvider();
// Act // Act
var mvcOptions = services.GetRequiredService<IOptions<MvcOptions>>().Value; var mvcOptions = services.GetRequiredService<IOptions<MvcOptions>>().Value;
var jsonOptions = services.GetRequiredService<IOptions<MvcJsonOptions>>().Value; var jsonOptions = services.GetRequiredService<IOptions<MvcJsonOptions>>().Value;
var razorPagesOptions = services.GetRequiredService<IOptions<RazorPagesOptions>>().Value;
// Assert // Assert
Assert.True(mvcOptions.SuppressBindingUndefinedValueToEnumType); Assert.True(mvcOptions.SuppressBindingUndefinedValueToEnumType);
Assert.Equal(InputFormatterExceptionPolicy.MalformedInputExceptions, mvcOptions.InputFormatterExceptionPolicy); Assert.Equal(InputFormatterExceptionPolicy.MalformedInputExceptions, mvcOptions.InputFormatterExceptionPolicy);
Assert.True(jsonOptions.AllowInputFormatterExceptionMessages); Assert.True(jsonOptions.AllowInputFormatterExceptionMessages);
Assert.True(razorPagesOptions.AllowAreas);
} }
[Fact(Skip = "#7157 - some settings have the wrong values, this test should pass once #7157 is fixed")] [Fact]
public void CompatibilitySwitches_Version_Latest() public void CompatibilitySwitches_Version_Latest()
{ {
// Arrange // Arrange
var serviceCollection = new ServiceCollection(); var serviceCollection = new ServiceCollection();
AddHostingServices(serviceCollection); AddHostingServices(serviceCollection);
serviceCollection.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_0); serviceCollection.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest);
var services = serviceCollection.BuildServiceProvider(); var services = serviceCollection.BuildServiceProvider();
// Act // Act
var mvcOptions = services.GetRequiredService<IOptions<MvcOptions>>().Value; var mvcOptions = services.GetRequiredService<IOptions<MvcOptions>>().Value;
var jsonOptions = services.GetRequiredService<IOptions<MvcJsonOptions>>().Value; var jsonOptions = services.GetRequiredService<IOptions<MvcJsonOptions>>().Value;
var razorPagesOptions = services.GetRequiredService<IOptions<RazorPagesOptions>>().Value;
// Assert // Assert
Assert.True(mvcOptions.SuppressBindingUndefinedValueToEnumType); Assert.True(mvcOptions.SuppressBindingUndefinedValueToEnumType);
Assert.Equal(InputFormatterExceptionPolicy.MalformedInputExceptions, mvcOptions.InputFormatterExceptionPolicy); Assert.Equal(InputFormatterExceptionPolicy.MalformedInputExceptions, mvcOptions.InputFormatterExceptionPolicy);
Assert.True(jsonOptions.AllowInputFormatterExceptionMessages); Assert.True(jsonOptions.AllowInputFormatterExceptionMessages);
Assert.True(razorPagesOptions.AllowAreas);
} }
// This just does the minimum needed to be able to resolve these options. // This just does the minimum needed to be able to resolve these options.