diff --git a/test/Microsoft.AspNetCore.Mvc.Abstractions.Test/ModelBinding/ModelStateDictionaryTest.cs b/test/Microsoft.AspNetCore.Mvc.Abstractions.Test/ModelBinding/ModelStateDictionaryTest.cs index 90abb75dd2..36a7f874c8 100644 --- a/test/Microsoft.AspNetCore.Mvc.Abstractions.Test/ModelBinding/ModelStateDictionaryTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Abstractions.Test/ModelBinding/ModelStateDictionaryTest.cs @@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding dictionary.Clear(); // Assert - Assert.Equal(0, dictionary.Count); + Assert.Empty(dictionary); Assert.Equal(0, dictionary.ErrorCount); Assert.Empty(dictionary); Assert.Equal(ModelValidationState.Valid, dictionary.ValidationState); @@ -135,7 +135,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding dictionary.Clear(); // Assert - Assert.Equal(0, dictionary.Count); + Assert.Empty(dictionary); Assert.Equal(0, dictionary.ErrorCount); Assert.Empty(dictionary); Assert.Equal(ModelValidationState.Valid, dictionary.ValidationState); @@ -180,7 +180,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding // Assert Assert.Equal(0, source.ErrorCount); - Assert.Equal(1, source.Count); + Assert.Single(source); Assert.Equal(ModelValidationState.Skipped, source["key"].ValidationState); } @@ -239,7 +239,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding // Assert Assert.Equal(0, source.ErrorCount); - Assert.Equal(1, source.Count); + Assert.Single(source); Assert.Equal(ModelValidationState.Valid, source["key"].ValidationState); } @@ -276,7 +276,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding // Assert Assert.Equal(2, target.ErrorCount); - Assert.Equal(1, target.Count); + Assert.Single(target); var actual = target["key"]; Assert.Equal(entry.RawValue, actual.RawValue); Assert.Equal(entry.AttemptedValue, actual.AttemptedValue); diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ControllerBaseTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ControllerBaseTest.cs index 19664bba03..f3626af235 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ControllerBaseTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ControllerBaseTest.cs @@ -2751,7 +2751,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Test // Assert Assert.False(result); - Assert.Equal(1, controller.ModelState.Count); + Assert.Single(controller.ModelState); var error = Assert.Single(controller.ModelState["Prefix.IntegerProperty"].Errors); Assert.Equal("Out of range!", error.ErrorMessage); } @@ -2787,7 +2787,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Test // Assert Assert.False(result); - Assert.Equal(1, controller.ModelState.Count); + Assert.Single(controller.ModelState); var error = Assert.Single(controller.ModelState["IntegerProperty"].Errors); Assert.Equal("Out of range!", error.ErrorMessage); } diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/DefaultObjectValidatorTests.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/DefaultObjectValidatorTests.cs index e6caec6464..883a485de2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/DefaultObjectValidatorTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/DefaultObjectValidatorTests.cs @@ -614,7 +614,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal // Assert Assert.True(modelState.IsValid); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); var entry = modelState["parameter"]; Assert.Equal(ModelValidationState.Valid, entry.ValidationState); diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ComplexTypeModelBinderTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ComplexTypeModelBinderTest.cs index 43300f7dbf..c188a909ef 100644 --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ComplexTypeModelBinderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/ModelBinding/Binders/ComplexTypeModelBinderTest.cs @@ -664,7 +664,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders // Assert var modelStateDictionary = bindingContext.ModelState; Assert.False(modelStateDictionary.IsValid); - Assert.Equal(1, modelStateDictionary.Count); + Assert.Single(modelStateDictionary); // Check Age error. ModelStateEntry entry; diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/BodyValidationIntegrationTests.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/BodyValidationIntegrationTests.cs index 27e48d1500..33b287aa97 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/BodyValidationIntegrationTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/BodyValidationIntegrationTests.cs @@ -578,7 +578,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Null(boundPerson.Address); Assert.False(modelState.IsValid); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); var state = modelState["CustomParameter.Address.Number"]; diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/CancellationTokenModelBinderIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/CancellationTokenModelBinderIntegrationTest.cs index 26552ccfce..9ce033b2a8 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/CancellationTokenModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/CancellationTokenModelBinderIntegrationTest.cs @@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests // ModelState Assert.True(modelState.IsValid); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); } [Fact] @@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests // ModelState Assert.True(modelState.IsValid); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ComplexTypeModelBinderIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ComplexTypeModelBinderIntegrationTest.cs index abd9e23933..49f64eacfa 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ComplexTypeModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ComplexTypeModelBinderIntegrationTest.cs @@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model.Customer.Address); Assert.Equal(AddressStreetContent, model.Customer.Address.Street); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -122,7 +122,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model.Customer.Address); Assert.Equal(AddressStreetContent, model.Customer.Address.Street); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -167,7 +167,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal("bill", model.Customer.Name); Assert.Null(model.Customer.Address); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -209,7 +209,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Null(model.Customer); Assert.Equal(10, model.ProductId); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -250,7 +250,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Customer); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -389,7 +389,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal("bill", model.Customer.Name); Assert.Null(model.Customer.Token); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -578,7 +578,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Null(model.Customer); Assert.Equal(10, model.ProductId); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -619,7 +619,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Customer); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -756,7 +756,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal("bill", model.Name); Assert.Null(model.ProductIds); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -795,7 +795,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Null(model.Name); Assert.Null(model.ProductIds); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -932,7 +932,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal("bill", model.Name); Assert.Null(model.ProductIds); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -971,7 +971,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Null(model.Name); Assert.Null(model.ProductIds); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -1108,7 +1108,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal("bill", model.Name); Assert.Null(model.ProductIds); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -1147,7 +1147,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Null(model.Name); Assert.Null(model.ProductIds); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -1609,7 +1609,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal("bill", model.Name); Assert.Equal(default(KeyValuePair), model.ProductId); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -1648,7 +1648,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Null(model.Name); Assert.Equal(default(KeyValuePair), model.ProductId); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -1784,7 +1784,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model.Customer.Address); Assert.Equal(AddressStreetContent, model.Customer.Address.Street); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -1826,7 +1826,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Customer); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -1873,7 +1873,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Customer); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -2074,7 +2074,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.ProductName); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -2118,7 +2118,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.ProductName); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -2158,7 +2158,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Equal("abc", model.ProductName); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -2202,7 +2202,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.OrderIds); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -2246,7 +2246,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.OrderIds); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -2286,7 +2286,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Equal(new[] { 123 }, model.OrderIds.ToArray()); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -2332,7 +2332,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model); Assert.Equal(0, model.ProductId); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/GenericModelBinderIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/GenericModelBinderIntegrationTest.cs index bf10111e82..acb91f6ed5 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/GenericModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/GenericModelBinderIntegrationTest.cs @@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Single(model); Assert.NotNull(model[0]); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -253,7 +253,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Single(model); Assert.Null(model[0]); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -378,7 +378,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model); Assert.Empty(model); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -501,7 +501,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model); Assert.Empty(model); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -633,7 +633,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model); Assert.Empty(model); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/KeyValuePairModelBinderIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/KeyValuePairModelBinderIntegrationTest.cs index 985fe67c2c..79c0803f15 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/KeyValuePairModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/KeyValuePairModelBinderIntegrationTest.cs @@ -332,7 +332,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal(new KeyValuePair(), modelBindingResult.Model); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -495,7 +495,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal(new KeyValuePair(), modelBindingResult.Model); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ModelPrefixSelectionIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ModelPrefixSelectionIntegrationTest.cs index 34de696859..7a03494307 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ModelPrefixSelectionIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ModelPrefixSelectionIntegrationTest.cs @@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Name); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Name); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -143,7 +143,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Name); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -192,7 +192,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Name); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -238,7 +238,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Name); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/SimpleTypeModelBinderIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/SimpleTypeModelBinderIntegrationTest.cs index daddf74bda..0d5cede662 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/SimpleTypeModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/SimpleTypeModelBinderIntegrationTest.cs @@ -274,7 +274,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests // ModelState Assert.False(modelState.IsValid); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); var key = Assert.Single(modelState.Keys); @@ -332,7 +332,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests // ModelState Assert.False(modelState.IsValid); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); var key = Assert.Single(modelState.Keys); diff --git a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ValidationIntegrationTests.cs b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ValidationIntegrationTests.cs index a0cc60067d..036f758433 100644 --- a/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ValidationIntegrationTests.cs +++ b/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ValidationIntegrationTests.cs @@ -187,7 +187,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Equal("bill", model.CustomerName); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -224,7 +224,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.CustomerName); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -276,7 +276,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model.Customer); Assert.Equal("bill", model.Customer.Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -313,7 +313,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Customer); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -367,7 +367,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model.Customer); Assert.Equal("bill", model.Customer.Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -459,7 +459,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.NotNull(model.Items); Assert.Equal(17, Assert.Single(model.Items).ItemId); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -497,7 +497,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Items); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -545,7 +545,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType>(modelBindingResult.Model); Assert.Equal(17, Assert.Single(model).ProductId); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -631,7 +631,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Equal("bill", model.Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -668,7 +668,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Equal("billybob", model.Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -719,7 +719,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Equal("bill", model.Customer.Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -756,7 +756,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Equal("billybob", model.Customer.Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -796,7 +796,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Null(model.Customer); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -854,7 +854,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Equal("bill", model.Customer.Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -961,7 +961,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType(modelBindingResult.Model); Assert.Equal("bill", Assert.Single(model.Products).Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -1049,7 +1049,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType>(modelBindingResult.Model); Assert.Equal("bill", Assert.Single(model).Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); @@ -1086,7 +1086,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType>(modelBindingResult.Model); Assert.Equal("billybob", Assert.Single(model).Name); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); Assert.Equal(1, modelState.ErrorCount); Assert.False(modelState.IsValid); @@ -1126,7 +1126,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests var model = Assert.IsType>(modelBindingResult.Model); Assert.Empty(model); - Assert.Equal(0, modelState.Count); + Assert.Empty(modelState); Assert.Equal(0, modelState.ErrorCount); Assert.True(modelState.IsValid); } @@ -1690,7 +1690,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal("Hello", message); Assert.True(modelState.IsValid); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); var entry = Assert.Single(modelState, kvp => kvp.Key == "CustomParameter.message"); Assert.Equal(ModelValidationState.Skipped, entry.Value.ValidationState); @@ -1732,7 +1732,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.IsType(modelBindingResult.Model); Assert.False(modelState.IsValid); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); var entry = Assert.Single(modelState, kvp => kvp.Key == "message"); Assert.Equal(ModelValidationState.Unvalidated, entry.Value.ValidationState); @@ -1778,7 +1778,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests Assert.Equal("Hello", message); Assert.False(modelState.IsValid); - Assert.Equal(1, modelState.Count); + Assert.Single(modelState); var entry = Assert.Single(modelState, kvp => kvp.Key == "other.key"); Assert.Equal(ModelValidationState.Unvalidated, entry.Value.ValidationState); diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/AttributeDictionaryTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/AttributeDictionaryTest.cs index d29e636726..93ae890858 100644 --- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/AttributeDictionaryTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/AttributeDictionaryTest.cs @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures attributes.Clear(); // Assert - Assert.Equal(0, attributes.Count); + Assert.Empty(attributes); Assert.Empty(attributes); } diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryOfTModelTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryOfTModelTest.cs index c656351cd5..31f0d036d6 100644 --- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryOfTModelTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryOfTModelTest.cs @@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures Assert.NotNull(viewData.TemplateInfo); Assert.Null(viewData.Model); Assert.NotNull(viewData.ModelMetadata); - Assert.Equal(0, viewData.Count); + Assert.Empty(viewData); } [Fact] diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryTest.cs index 29119ffa75..cfcb4bf426 100644 --- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataDictionaryTest.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures Assert.NotNull(viewData.TemplateInfo); Assert.Null(viewData.Model); Assert.NotNull(viewData.ModelMetadata); - Assert.Equal(0, viewData.Count); + Assert.Empty(viewData); } [Fact] @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures Assert.NotNull(viewData.TemplateInfo); Assert.Null(viewData.Model); Assert.NotNull(viewData.ModelMetadata); - Assert.Equal(0, viewData.Count); + Assert.Empty(viewData); } [Fact] diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataOfTTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataOfTTest.cs index 6297e7e0c8..3e3dbaf198 100644 --- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataOfTTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewFeatures/ViewDataOfTTest.cs @@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures // Act & Assert Assert.Empty(viewData); - Assert.Equal(0, viewData.Count); + Assert.Empty(viewData); Assert.False(viewData.IsReadOnly); Assert.NotNull(viewData.Keys);