Skip to content

Commit f098836

Browse files
committed
Enlarge an xUnit collection to include all ModelMetadataProviders.Current readers
- #41 - have not seen similar `InvalidOperationException`s in other test classes - `DisplayExtensionsTest` and `EditorExtensionsTest` are already in this increasingly-poorly named collection - they temporarily change `ModelMetadataProviders.Current` to reference a `Mock<ModelMetadataProvider>` This is a **temporary** fix: should use `[CollectionDefinition(DisableParallelization = true)]` xUnit v2.3.0 - i.e. create an isolated collection containing just `DisplayExtensionsTest` and `EditorExtensionsTest`
1 parent d86dda5 commit f098836

20 files changed

+22
-4
lines changed

test/System.Web.Mvc.Test/Html/Test/DefaultDisplayTemplatesTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace System.Web.Mvc.Html.Test
1515
{
16+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1617
public class DefaultDisplayTemplatesTest
1718
{
1819
// BooleanTemplate

test/System.Web.Mvc.Test/Test/AssociatedValidatorProviderTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace System.Web.Mvc.Test
1111
{
12+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1213
public class AssociatedValidatorProviderTest
1314
{
1415
[Fact]

test/System.Web.Mvc.Test/Test/CompareAttributeAdapterTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace System.Web.Mvc.Test
1111
{
12+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1213
public class CompareAttributeAdapterTest
1314
{
1415
[Fact]

test/System.Web.Mvc.Test/Test/CompareAttributeTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace System.Web.Mvc.Test
1010
{
11+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1112
public class CompareAttributeTest
1213
{
1314
[Fact]

test/System.Web.Mvc.Test/Test/ControllerActionInvokerTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
namespace System.Web.Mvc.Test
2020
{
21+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
2122
public class ControllerActionInvokerTest
2223
{
2324
[Fact]

test/System.Web.Mvc.Test/Test/DataAnnotationsModelValidatorProviderTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace System.Web.Mvc.Test
1313
{
14+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1415
public class DataAnnotationsModelValidatorProviderTest
1516
{
1617
// Validation attribute adapter registration

test/System.Web.Mvc.Test/Test/DataAnnotationsModelValidatorTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace System.Web.Mvc.Test
1212
{
13+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1314
public class DataAnnotationsModelValidatorTest
1415
{
1516
[Fact]

test/System.Web.Mvc.Test/Test/DefaultModelBinderTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace System.Web.Mvc.Test
1717
{
18+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1819
public class DefaultModelBinderTest
1920
{
2021
[Fact]

test/System.Web.Mvc.Test/Test/MaxLengthAttributeAdapterTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.ComponentModel.DataAnnotations;
5-
using System.Linq;
65
using Microsoft.TestCommon;
76

87
namespace System.Web.Mvc.Test
98
{
9+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1010
public class MaxLengthAttributeAdapterTest
1111
{
1212
[Fact]

test/System.Web.Mvc.Test/Test/MinLengthAttributeAdapterTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System.ComponentModel.DataAnnotations;
5-
using System.Linq;
65
using Microsoft.TestCommon;
76

87
namespace System.Web.Mvc.Test
98
{
9+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1010
public class MinLengthAttributeAdapterTest
1111
{
1212
[Fact]

test/System.Web.Mvc.Test/Test/ModelBindingContextTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace System.Web.Mvc.Test
99
{
10+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1011
public class ModelBindingContextTest
1112
{
1213
[Fact]

test/System.Web.Mvc.Test/Test/ModelMetadataTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace System.Web.Mvc.Test
1212
{
13+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1314
public class ModelMetadataTest
1415
{
1516
// Guard clauses
@@ -826,7 +827,7 @@ public void FromLambdaExpressionSetsContainerTypeToDerivedMostType()
826827
Assert.Equal(derivedModel.GetType(), type);
827828
Assert.Equal("MyProperty", propertyName);
828829
})
829-
.Returns<Func<object>, Type, string>((accessor, type, propertyName) =>
830+
.Returns<Func<object>, Type, string>((accessor, type, propertyName) =>
830831
{
831832
return new ModelMetadata(provider.Object, derivedModel.GetType(), accessor, type, propertyName);
832833
})

test/System.Web.Mvc.Test/Test/ModelValidatorTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace System.Web.Mvc.Test
1010
{
11+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1112
public class ModelValidatorTest
1213
{
1314
[Fact]

test/System.Web.Mvc.Test/Test/RangeAttributeAdapterTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace System.Web.Mvc.Test
99
{
10+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1011
public class RangeAttributeAdapterTest
1112
{
1213
[Fact]

test/System.Web.Mvc.Test/Test/RegularExpressionAttributeAdapterTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace System.Web.Mvc.Test
99
{
10+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1011
public class RegularExpressionAttributeAdapterTest
1112
{
1213
[Fact]

test/System.Web.Mvc.Test/Test/RemoteAttributeTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace System.Web.Mvc.Test
1111
{
12+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1213
public class RemoteAttributeTest
1314
{
1415
// Good route name, bad route name
@@ -261,7 +262,7 @@ public void ActionControllerAreaReference_WithUseRoot_RemoteFindsControllerInRoo
261262
[Fact]
262263
public void ActionController_InArea_RemoteFindsControllerInCurrentArea()
263264
{
264-
// Arrange
265+
// Arrange
265266
ModelMetadata metadata = ModelMetadataProviders.Current.GetMetadataForProperty(modelAccessor: null,
266267
containerType: typeof(string), propertyName: "Length");
267268
TestableRemoteAttribute attribute = new TestableRemoteAttribute("Action", "Controller");

test/System.Web.Mvc.Test/Test/RequiredAttributeAdapterTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace System.Web.Mvc.Test
99
{
10+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1011
public class RequiredAttributeAdapterTest
1112
{
1213
[Fact]

test/System.Web.Mvc.Test/Test/StringLengthAttributeAdapterTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace System.Web.Mvc.Test
99
{
10+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1011
public class StringLengthAttributeAdapterTest
1112
{
1213
[Fact]

test/System.Web.Mvc.Test/Test/ValidatableObjectAdapterTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace System.Web.Mvc.Test
1111
{
12+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1213
public class ValidatableObjectAdapterTest
1314
{
1415
// IValidatableObject support

test/System.Web.Mvc.Test/Test/ViewDataDictionaryTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace System.Web.Mvc.Test
1111
{
12+
[Xunit.Collection("Uses ScopeStorage or ViewEngines.Engines")] // Uses ModelMetadataProviders.Current
1213
public class ViewDataDictionaryTest
1314
{
1415
[Fact]

0 commit comments

Comments
 (0)