diff --git a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelState.cs b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelState.cs
index 213b8b6922..19c4a41d28 100644
--- a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelState.cs
+++ b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelState.cs
@@ -6,7 +6,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
///
/// An entry in a .
///
- public class ModelState
+ public class ModelStateEntry
{
///
/// Gets the raw value from the request associated with this entry.
diff --git a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelStateDictionary.cs b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelStateDictionary.cs
index 49ed8d4e4b..8245161971 100644
--- a/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelStateDictionary.cs
+++ b/src/Microsoft.AspNet.Mvc.Abstractions/ModelBinding/ModelStateDictionary.cs
@@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
/// Represents the state of an attempt to bind values from an HTTP Request to an action method, which includes
/// validation information.
///
- public class ModelStateDictionary : IDictionary
+ public class ModelStateDictionary : IDictionary
{
// Make sure to update the doc headers if this value is changed.
///
@@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
///
public static readonly int DefaultMaxAllowedErrors = 200;
- private readonly Dictionary _innerDictionary;
+ private readonly Dictionary _innerDictionary;
private int _maxAllowedErrors;
///
@@ -38,7 +38,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
MaxAllowedErrors = maxAllowedErrors;
- _innerDictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ _innerDictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
}
///
@@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
throw new ArgumentNullException(nameof(dictionary));
}
- _innerDictionary = new Dictionary(
+ _innerDictionary = new Dictionary(
dictionary,
StringComparer.OrdinalIgnoreCase);
@@ -74,7 +74,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
/// the error message will be ignored and a will be added.
///
///
- /// Errors added via modifying directly do not count towards this limit.
+ /// Errors added via modifying directly do not count towards this limit.
///
///
public int MaxAllowedErrors
@@ -122,7 +122,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
///
public bool IsReadOnly
{
- get { return ((ICollection>)_innerDictionary).IsReadOnly; }
+ get { return ((ICollection>)_innerDictionary).IsReadOnly; }
}
///
@@ -132,7 +132,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- public ICollection Values
+ public ICollection Values
{
get { return _innerDictionary.Values; }
}
@@ -159,7 +159,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- public ModelState this[string key]
+ public ModelStateEntry this[string key]
{
get
{
@@ -168,7 +168,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
throw new ArgumentNullException(nameof(key));
}
- ModelState value;
+ ModelStateEntry value;
_innerDictionary.TryGetValue(key, out value);
return value;
}
@@ -188,7 +188,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
// For unit testing
- internal IDictionary InnerDictionary
+ internal IDictionary InnerDictionary
{
get { return _innerDictionary; }
}
@@ -197,10 +197,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
private bool HasRecordedMaxModelError { get; set; }
///
- /// Adds the specified to the instance
+ /// Adds the specified to the instance
/// that is associated with the specified .
///
- /// The key of the to add errors to.
+ /// The key of the to add errors to.
/// The to add.
public void AddModelError(string key, Exception exception)
{
@@ -218,11 +218,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Attempts to add the specified to the
+ /// Attempts to add the specified to the
/// instance that is associated with the specified . If the maximum number of allowed
/// errors has already been recorded, records a exception instead.
///
- /// The key of the to add errors to.
+ /// The key of the to add errors to.
/// The to add.
///
/// True if the given error was added, false if the error was ignored.
@@ -249,18 +249,18 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
if (exception is FormatException || exception is OverflowException)
{
// Convert FormatExceptions and OverflowExceptions to Invalid value messages.
- ModelState modelState;
- TryGetValue(key, out modelState);
+ ModelStateEntry entry;
+ TryGetValue(key, out entry);
string errorMessage;
- if (modelState == null)
+ if (entry == null)
{
errorMessage = Resources.FormatModelError_InvalidValue_GenericMessage(key);
}
else
{
errorMessage = Resources.FormatModelError_InvalidValue_MessageWithModelValue(
- modelState.AttemptedValue,
+ entry.AttemptedValue,
key);
}
@@ -273,10 +273,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Adds the specified to the instance
+ /// Adds the specified to the instance
/// that is associated with the specified .
///
- /// The key of the to add errors to.
+ /// The key of the to add errors to.
/// The error message to add.
public void AddModelError(string key, string errorMessage)
{
@@ -294,11 +294,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Attempts to add the specified to the
+ /// Attempts to add the specified to the
/// instance that is associated with the specified . If the maximum number of allowed
/// errors has already been recorded, records a exception instead.
///
- /// The key of the to add errors to.
+ /// The key of the to add errors to.
/// The error message to add.
///
/// True if the given error was added, false if the error was ignored.
@@ -363,7 +363,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
throw new ArgumentNullException(nameof(key));
}
- ModelState validationState;
+ ModelStateEntry validationState;
if (TryGetValue(key, out validationState))
{
return validationState.ValidationState;
@@ -373,10 +373,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Marks the for the entry with the specified
- /// as .
+ /// Marks the for the entry with the specified
+ /// as .
///
- /// The key of the to mark as valid.
+ /// The key of the to mark as valid.
public void MarkFieldValid(string key)
{
if (key == null)
@@ -394,10 +394,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Marks the for the entry with the specified
+ /// Marks the for the entry with the specified
/// as .
///
- /// The key of the to mark as skipped.
+ /// The key of the to mark as skipped.
public void MarkFieldSkipped(string key)
{
if (key == null)
@@ -433,11 +433,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Sets the of and for
- /// the with the specified .
+ /// Sets the of and for
+ /// the with the specified .
///
- /// The key for the entry.
- /// The raw value for the entry.
+ /// The key for the entry.
+ /// The raw value for the entry.
///
/// The values of in a comma-separated .
///
@@ -454,11 +454,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Sets the value for the with the specified .
+ /// Sets the value for the with the specified .
///
- /// The key for the entry
+ /// The key for the entry
///
- /// A with data for the entry.
+ /// A with data for the entry.
///
public void SetModelValue(string key, ValueProviderResult valueProviderResult)
{
@@ -501,21 +501,21 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
}
- private ModelState GetModelStateForKey(string key)
+ private ModelStateEntry GetModelStateForKey(string key)
{
if (key == null)
{
throw new ArgumentNullException(nameof(key));
}
- ModelState modelState;
- if (!TryGetValue(key, out modelState))
+ ModelStateEntry entry;
+ if (!TryGetValue(key, out entry))
{
- modelState = new ModelState();
- this[key] = modelState;
+ entry = new ModelStateEntry();
+ this[key] = entry;
}
- return modelState;
+ return entry;
}
private static ModelValidationState GetValidity(PrefixEnumerable entries, ModelValidationState defaultState)
@@ -562,13 +562,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- public void Add(KeyValuePair item)
+ public void Add(KeyValuePair item)
{
Add(item.Key, item.Value);
}
///
- public void Add(string key, ModelState value)
+ public void Add(string key, ModelStateEntry value)
{
if (key == null)
{
@@ -590,9 +590,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- public bool Contains(KeyValuePair item)
+ public bool Contains(KeyValuePair item)
{
- return ((ICollection>)_innerDictionary).Contains(item);
+ return ((ICollection>)_innerDictionary).Contains(item);
}
///
@@ -607,20 +607,20 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- public void CopyTo(KeyValuePair[] array, int arrayIndex)
+ public void CopyTo(KeyValuePair[] array, int arrayIndex)
{
if (array == null)
{
throw new ArgumentNullException(nameof(array));
}
- ((ICollection>)_innerDictionary).CopyTo(array, arrayIndex);
+ ((ICollection>)_innerDictionary).CopyTo(array, arrayIndex);
}
///
- public bool Remove(KeyValuePair item)
+ public bool Remove(KeyValuePair item)
{
- return ((ICollection>)_innerDictionary).Remove(item);
+ return ((ICollection>)_innerDictionary).Remove(item);
}
///
@@ -635,7 +635,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- public bool TryGetValue(string key, out ModelState value)
+ public bool TryGetValue(string key, out ModelStateEntry value)
{
if (key == null)
{
@@ -646,7 +646,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- public IEnumerator> GetEnumerator()
+ public IEnumerator> GetEnumerator()
{
return _innerDictionary.GetEnumerator();
}
@@ -732,7 +732,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
return new PrefixEnumerable(this, prefix);
}
- public struct PrefixEnumerable : IEnumerable>
+ public struct PrefixEnumerable : IEnumerable>
{
private readonly ModelStateDictionary _dictionary;
private readonly string _prefix;
@@ -758,7 +758,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
return _dictionary == null ? new PrefixEnumerator() : new PrefixEnumerator(_dictionary, _prefix);
}
- IEnumerator> IEnumerable>.GetEnumerator()
+ IEnumerator>
+ IEnumerable>.GetEnumerator()
{
return GetEnumerator();
}
@@ -769,13 +770,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
}
- public struct PrefixEnumerator : IEnumerator>
+ public struct PrefixEnumerator : IEnumerator>
{
private readonly ModelStateDictionary _dictionary;
private readonly string _prefix;
private bool _exactMatchUsed;
- private Dictionary.Enumerator _enumerator;
+ private Dictionary.Enumerator _enumerator;
public PrefixEnumerator(ModelStateDictionary dictionary, string prefix)
{
@@ -793,11 +794,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
_prefix = prefix;
_exactMatchUsed = false;
- _enumerator = default(Dictionary.Enumerator);
- Current = default(KeyValuePair);
+ _enumerator = default(Dictionary.Enumerator);
+ Current = default(KeyValuePair);
}
- public KeyValuePair Current { get; private set; }
+ public KeyValuePair Current { get; private set; }
object IEnumerator.Current
{
@@ -826,10 +827,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
_exactMatchUsed = true;
_enumerator = _dictionary._innerDictionary.GetEnumerator();
- ModelState entry;
+ ModelStateEntry entry;
if (_dictionary.TryGetValue(_prefix, out entry))
{
- Current = new KeyValuePair(_prefix, entry);
+ Current = new KeyValuePair(_prefix, entry);
return true;
}
}
@@ -853,8 +854,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void Reset()
{
_exactMatchUsed = false;
- _enumerator = default(Dictionary.Enumerator);
- Current = default(KeyValuePair);
+ _enumerator = default(Dictionary.Enumerator);
+ Current = default(KeyValuePair);
}
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Core/SerializableError.cs b/src/Microsoft.AspNet.Mvc.Core/SerializableError.cs
index 064c7a2183..7b5275944f 100644
--- a/src/Microsoft.AspNet.Mvc.Core/SerializableError.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/SerializableError.cs
@@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc
///
/// Creates a new instance of .
///
- /// containing the validation errors.
+ /// containing the validation errors.
public SerializableError(ModelStateDictionary modelState)
: this()
{
diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/Internal/ValidationHelpers.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/Internal/ValidationHelpers.cs
index 34110c823c..1ea1314701 100644
--- a/src/Microsoft.AspNet.Mvc.ViewFeatures/Internal/ValidationHelpers.cs
+++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/Internal/ValidationHelpers.cs
@@ -10,30 +10,30 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
{
internal static class ValidationHelpers
{
- public static string GetUserErrorMessageOrDefault(ModelError modelError, ModelState modelState)
+ public static string GetUserErrorMessageOrDefault(ModelError modelError, ModelStateEntry entry)
{
if (!string.IsNullOrEmpty(modelError.ErrorMessage))
{
return modelError.ErrorMessage;
}
- if (modelState == null)
+ if (entry == null)
{
return string.Empty;
}
- var attemptedValue = modelState.AttemptedValue ?? "null";
+ var attemptedValue = entry.AttemptedValue ?? "null";
return Resources.FormatCommon_ValueNotValidForProperty(attemptedValue);
}
// Returns non-null list of model states, which caller will render in order provided.
- public static IEnumerable GetModelStateList(
+ public static IEnumerable GetModelStateList(
ViewDataDictionary viewData,
bool excludePropertyErrors)
{
if (excludePropertyErrors)
{
- ModelState ms;
+ ModelStateEntry ms;
viewData.ModelState.TryGetValue(viewData.TemplateInfo.HtmlFieldPrefix, out ms);
if (ms != null)
@@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
return new[] { ms };
}
- return Enumerable.Empty();
+ return Enumerable.Empty();
}
else
{
@@ -58,7 +58,8 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
// ModelState doesn't refer to ModelMetadata, but we can correlate via the property name.
private class ErrorsOrderer
{
- private Dictionary _ordering = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ private readonly Dictionary _ordering =
+ new Dictionary(StringComparer.OrdinalIgnoreCase);
public ErrorsOrderer(ModelMetadata metadata)
{
diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ModelStateDictionaryExtensions.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ModelStateDictionaryExtensions.cs
index 6cf6f24c1b..4e65b3ba9c 100644
--- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ModelStateDictionaryExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ModelStateDictionaryExtensions.cs
@@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public static class ModelStateDictionaryExtensions
{
///
- /// Adds the specified to the instance
+ /// Adds the specified to the instance
/// that is associated with the specified .
///
/// The type of the model.
@@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
}
///
- /// Adds the specified to the instance
+ /// Adds the specified to the instance
/// that is associated with the specified .
///
/// The type of the model.
diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultHtmlGenerator.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultHtmlGenerator.cs
index a8b02d3014..65083dcc41 100644
--- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultHtmlGenerator.cs
+++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ViewFeatures/DefaultHtmlGenerator.cs
@@ -546,10 +546,10 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
}
// If there are any errors for a named field, we add the css attribute.
- ModelState modelState;
- if (viewContext.ViewData.ModelState.TryGetValue(fullName, out modelState))
+ ModelStateEntry entry;
+ if (viewContext.ViewData.ModelState.TryGetValue(fullName, out entry))
{
- if (modelState.Errors.Count > 0)
+ if (entry.Errors.Count > 0)
{
tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName);
}
@@ -599,13 +599,13 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
nameof(expression));
}
- ModelState modelState;
- viewContext.ViewData.ModelState.TryGetValue(fullName, out modelState);
+ ModelStateEntry entry;
+ viewContext.ViewData.ModelState.TryGetValue(fullName, out entry);
var value = string.Empty;
- if (modelState != null && modelState.AttemptedValue != null)
+ if (entry != null && entry.AttemptedValue != null)
{
- value = modelState.AttemptedValue;
+ value = entry.AttemptedValue;
}
else if (modelExplorer.Model != null)
{
@@ -629,7 +629,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, modelExplorer, expression));
// If there are any errors for a named field, we add this CSS attribute.
- if (modelState != null && modelState.Errors.Count > 0)
+ if (entry != null && entry.Errors.Count > 0)
{
tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName);
}
@@ -703,9 +703,9 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
return null;
}
- ModelState modelState;
- var tryGetModelStateResult = viewContext.ViewData.ModelState.TryGetValue(fullName, out modelState);
- var modelErrors = tryGetModelStateResult ? modelState.Errors : null;
+ ModelStateEntry entry;
+ var tryGetModelStateResult = viewContext.ViewData.ModelState.TryGetValue(fullName, out entry);
+ var modelErrors = tryGetModelStateResult ? entry.Errors : null;
ModelError modelError = null;
if (modelErrors != null && modelErrors.Count != 0)
@@ -741,7 +741,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
else if (modelError != null)
{
tagBuilder.InnerHtml.SetContent(
- ValidationHelpers.GetUserErrorMessageOrDefault(modelError, modelState));
+ ValidationHelpers.GetUserErrorMessageOrDefault(modelError, entry));
}
if (formContext != null)
@@ -804,7 +804,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
for (var i = 0; i < modelState.Errors.Count; i++)
{
var modelError = modelState.Errors[i];
- var errorText = ValidationHelpers.GetUserErrorMessageOrDefault(modelError, modelState: null);
+ var errorText = ValidationHelpers.GetUserErrorMessageOrDefault(modelError, entry: null);
if (!string.IsNullOrEmpty(errorText))
{
@@ -1056,10 +1056,10 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
internal static object GetModelStateValue(ViewContext viewContext, string key, Type destinationType)
{
- ModelState modelState;
- if (viewContext.ViewData.ModelState.TryGetValue(key, out modelState) && modelState.RawValue != null)
+ ModelStateEntry entry;
+ if (viewContext.ViewData.ModelState.TryGetValue(key, out entry) && entry.RawValue != null)
{
- return ModelBindingHelper.ConvertTo(modelState.RawValue, destinationType, culture: null);
+ return ModelBindingHelper.ConvertTo(entry.RawValue, destinationType, culture: null);
}
return null;
@@ -1228,8 +1228,8 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
}
// If there are any errors for a named field, we add the CSS attribute.
- ModelState modelState;
- if (viewContext.ViewData.ModelState.TryGetValue(fullName, out modelState) && modelState.Errors.Count > 0)
+ ModelStateEntry entry;
+ if (viewContext.ViewData.ModelState.TryGetValue(fullName, out entry) && entry.Errors.Count > 0)
{
tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName);
}
diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpError.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpError.cs
index 18c8df65c3..f3c7d4d6c6 100644
--- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpError.cs
+++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpError.cs
@@ -95,7 +95,7 @@ namespace System.Web.Http
Message = ShimResources.HttpError_BadRequest;
var modelStateError = new HttpError();
- foreach (KeyValuePair keyModelStatePair in modelState)
+ foreach (KeyValuePair keyModelStatePair in modelState)
{
var key = keyModelStatePair.Key;
var errors = keyModelStatePair.Value.Errors;
diff --git a/test/Microsoft.AspNet.Mvc.Abstractions.Test/ModelBinding/ModelStateDictionaryTest.cs b/test/Microsoft.AspNet.Mvc.Abstractions.Test/ModelBinding/ModelStateDictionaryTest.cs
index e376a1f9f2..2bc7e3667e 100644
--- a/test/Microsoft.AspNet.Mvc.Abstractions.Test/ModelBinding/ModelStateDictionaryTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Abstractions.Test/ModelBinding/ModelStateDictionaryTest.cs
@@ -15,14 +15,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void MarkFieldSkipped_MarksFieldAsSkipped_IfStateIsNotInValid(ModelValidationState validationState)
{
// Arrange
- var modelState = new ModelState
+ var entry = new ModelStateEntry
{
ValidationState = validationState
};
var source = new ModelStateDictionary
{
- { "key", modelState }
+ { "key", entry }
};
// Act
@@ -36,14 +36,12 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void MarkFieldSkipped_MarksFieldAsSkipped_IfKeyIsNotPresent()
{
// Arrange
- var modelState = new ModelState
+ var entry = new ModelStateEntry
{
ValidationState = ModelValidationState.Valid
};
- var source = new ModelStateDictionary
- {
- };
+ var source = new ModelStateDictionary();
// Act
source.MarkFieldSkipped("key");
@@ -58,14 +56,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void MarkFieldSkipped_Throws_IfStateIsInvalid()
{
// Arrange
- var modelState = new ModelState
+ var entry = new ModelStateEntry
{
ValidationState = ModelValidationState.Invalid
};
var source = new ModelStateDictionary
{
- { "key", modelState }
+ { "key", entry }
};
// Act
@@ -83,14 +81,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void MarkFieldValid_MarksFieldAsValid_IfStateIsNotInvalid(ModelValidationState validationState)
{
// Arrange
- var modelState = new ModelState
+ var entry = new ModelStateEntry
{
ValidationState = validationState
};
var source = new ModelStateDictionary
{
- { "key", modelState }
+ { "key", entry }
};
// Act
@@ -119,14 +117,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void MarkFieldValid_Throws_IfStateIsInvalid()
{
// Arrange
- var modelState = new ModelState
+ var entry = new ModelStateEntry
{
ValidationState = ModelValidationState.Invalid
};
var source = new ModelStateDictionary
{
- { "key", modelState }
+ { "key", entry }
};
// Act
@@ -142,10 +140,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void CopyConstructor_CopiesModelStateData()
{
// Arrange
- var modelState = new ModelState();
+ var entry = new ModelStateEntry();
var source = new ModelStateDictionary
{
- { "key", modelState }
+ { "key", entry }
};
// Act
@@ -154,8 +152,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Assert
Assert.Equal(0, target.ErrorCount);
Assert.Equal(1, target.Count);
- Assert.Same(modelState, target["key"]);
- Assert.IsType>(target.InnerDictionary);
+ Assert.Same(entry, target["key"]);
+ Assert.IsType>(target.InnerDictionary);
}
[Fact]
@@ -202,7 +200,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var oldDictionary = new ModelStateDictionary()
{
- { "foo", new ModelState() { RawValue = "bar" } }
+ { "foo", new ModelStateEntry() { RawValue = "bar" } }
};
// Act
@@ -217,10 +215,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void GetFieldValidationState_ReturnsUnvalidatedIfDictionaryDoesNotContainKey()
{
// Arrange
- var msd = new ModelStateDictionary();
+ var dictionary = new ModelStateDictionary();
// Act
- var validationState = msd.GetFieldValidationState("foo");
+ var validationState = dictionary.GetFieldValidationState("foo");
// Assert
Assert.Equal(ModelValidationState.Unvalidated, validationState);
@@ -230,11 +228,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void GetValidationState_ReturnsValidationStateForKey_IgnoresChildren()
{
// Arrange
- var msd = new ModelStateDictionary();
- msd.AddModelError("foo.bar", "error text");
+ var dictionary = new ModelStateDictionary();
+ dictionary.AddModelError("foo.bar", "error text");
// Act
- var validationState = msd.GetValidationState("foo");
+ var validationState = dictionary.GetValidationState("foo");
// Assert
Assert.Equal(ModelValidationState.Unvalidated, validationState);
@@ -248,11 +246,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void GetFieldValidationState_ReturnsInvalidIfKeyChildContainsErrors(string key)
{
// Arrange
- var msd = new ModelStateDictionary();
- msd.AddModelError(key, "error text");
+ var dictionary = new ModelStateDictionary();
+ dictionary.AddModelError(key, "error text");
// Act
- var validationState = msd.GetFieldValidationState("foo");
+ var validationState = dictionary.GetFieldValidationState("foo");
// Assert
Assert.Equal(ModelValidationState.Invalid, validationState);
@@ -266,17 +264,17 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void GetFieldValidationState_ReturnsValidIfModelStateDoesNotContainErrors(string key)
{
// Arrange
- var validState = new ModelState
+ var validState = new ModelStateEntry
{
ValidationState = ModelValidationState.Valid
};
- var msd = new ModelStateDictionary
+ var dictionary = new ModelStateDictionary
{
{ key, validState }
};
// Act
- var validationState = msd.GetFieldValidationState("foo");
+ var validationState = dictionary.GetFieldValidationState("foo");
// Assert
Assert.Equal(ModelValidationState.Valid, validationState);
@@ -288,11 +286,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void GetFieldValidationState_IndexedPrefix_ReturnsInvalidIfKeyChildContainsErrors(string key)
{
// Arrange
- var msd = new ModelStateDictionary();
- msd.AddModelError(key, "error text");
+ var dictionary = new ModelStateDictionary();
+ dictionary.AddModelError(key, "error text");
// Act
- var validationState = msd.GetFieldValidationState("[0].foo");
+ var validationState = dictionary.GetFieldValidationState("[0].foo");
// Assert
Assert.Equal(ModelValidationState.Invalid, validationState);
@@ -304,17 +302,17 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void GetFieldValidationState_IndexedPrefix_ReturnsValidIfModelStateDoesNotContainErrors(string key)
{
// Arrange
- var validState = new ModelState
+ var validState = new ModelStateEntry
{
ValidationState = ModelValidationState.Valid
};
- var msd = new ModelStateDictionary
+ var dictionary = new ModelStateDictionary
{
{ key, validState }
};
// Act
- var validationState = msd.GetFieldValidationState("[0].foo");
+ var validationState = dictionary.GetFieldValidationState("[0].foo");
// Assert
Assert.Equal(ModelValidationState.Valid, validationState);
@@ -324,11 +322,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void IsValidPropertyReturnsFalseIfErrors()
{
// Arrange
- var errorState = new ModelState
+ var errorState = new ModelStateEntry
{
ValidationState = ModelValidationState.Invalid
};
- var validState = new ModelState
+ var validState = new ModelStateEntry
{
ValidationState = ModelValidationState.Valid
};
@@ -354,15 +352,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var dictionary = new ModelStateDictionary()
{
- { "foo", new ModelState
- {
- ValidationState = ModelValidationState.Valid,
- }
+ { "foo", new ModelStateEntry
+ {
+ ValidationState = ModelValidationState.Valid,
+ }
},
- { "baz", new ModelState
- {
- ValidationState = ModelValidationState.Skipped,
- }
+ { "baz", new ModelStateEntry
+ {
+ ValidationState = ModelValidationState.Skipped,
+ }
}
};
@@ -379,11 +377,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void IsValidPropertyReturnsFalse_IfSomeFieldsAreNotValidated()
{
// Arrange
- var errorState = new ModelState
+ var errorState = new ModelStateEntry
{
ValidationState = ModelValidationState.Invalid
};
- var validState = new ModelState
+ var validState = new ModelStateEntry
{
ValidationState = ModelValidationState.Valid
};
@@ -392,7 +390,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
{ "foo", validState },
{ "baz", errorState },
- { "qux", new ModelState() }
+ { "qux", new ModelStateEntry() }
};
// Act
@@ -408,29 +406,29 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void MergeCopiesDictionaryEntries()
{
// Arrange
- var fooDict = new ModelStateDictionary() { { "foo", new ModelState() } };
- var barDict = new ModelStateDictionary() { { "bar", new ModelState() } };
+ var dictionary1 = new ModelStateDictionary { { "foo", new ModelStateEntry() } };
+ var dictionary2 = new ModelStateDictionary { { "bar", new ModelStateEntry() } };
// Act
- fooDict.Merge(barDict);
+ dictionary1.Merge(dictionary2);
// Assert
- Assert.Equal(2, fooDict.Count);
- Assert.Equal(barDict["bar"], fooDict["bar"]);
+ Assert.Equal(2, dictionary1.Count);
+ Assert.Equal(dictionary2["bar"], dictionary1["bar"]);
}
[Fact]
public void MergeDoesNothingIfParameterIsNull()
{
// Arrange
- var fooDict = new ModelStateDictionary() { { "foo", new ModelState() } };
+ var dictionary = new ModelStateDictionary() { { "foo", new ModelStateEntry() } };
// Act
- fooDict.Merge(null);
+ dictionary.Merge(null);
// Assert
- Assert.Single(fooDict);
- Assert.True(fooDict.ContainsKey("foo"));
+ Assert.Single(dictionary);
+ Assert.True(dictionary.ContainsKey("foo"));
}
[Fact]
@@ -491,7 +489,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary["user.Address"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["user.Address"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
dictionary.SetModelValue("user.Name", new string[] { "some value" }, "some value");
dictionary.AddModelError("user.Age", "Age is not a valid int");
@@ -510,11 +508,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary["user.Address"] = new ModelState { ValidationState = ModelValidationState.Valid };
- dictionary["user.Name"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["user.Address"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
+ dictionary["user.Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
dictionary.AddModelError("user.Age", "Age is not a valid int");
- dictionary["[0].product.Name"] = new ModelState { ValidationState = ModelValidationState.Valid };
- dictionary["[0].product.Age[0]"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["[0].product.Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
+ dictionary["[0].product.Age[0]"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
dictionary.AddModelError("[1].product.Name", "Name is invalid");
// Act
@@ -529,8 +527,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary["user.Address"] = new ModelState { ValidationState = ModelValidationState.Valid };
- dictionary["user.Name"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["user.Address"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
+ dictionary["user.Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
// Act
var validationState = dictionary.GetFieldValidationState("user");
@@ -761,15 +759,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary["Property1"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["Property1"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
- dictionary["Property2"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Property2"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Property2", "Property2 invalid.");
- dictionary["Property3"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Property3"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Property3", "Property invalid.");
- dictionary["Property4"] = new ModelState { ValidationState = ModelValidationState.Skipped };
+ dictionary["Property4"] = new ModelStateEntry { ValidationState = ModelValidationState.Skipped };
// Act
dictionary.ClearValidationState("Property1");
@@ -793,22 +791,22 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary["Product"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["Product"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
- dictionary["Product.Detail1"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Product.Detail1"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Product.Detail1", "Product Detail1 invalid.");
- dictionary["Product.Detail2[0]"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Product.Detail2[0]"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Product.Detail2[0]", "Product Detail2[0] invalid.");
- dictionary["Product.Detail2[1]"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Product.Detail2[1]"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Product.Detail2[1]", "Product Detail2[1] invalid.");
- dictionary["Product.Detail2[2]"] = new ModelState { ValidationState = ModelValidationState.Skipped };
+ dictionary["Product.Detail2[2]"] = new ModelStateEntry { ValidationState = ModelValidationState.Skipped };
- dictionary["Product.Detail3"] = new ModelState { ValidationState = ModelValidationState.Skipped };
+ dictionary["Product.Detail3"] = new ModelStateEntry { ValidationState = ModelValidationState.Skipped };
- dictionary["ProductName"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["ProductName"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("ProductName", "ProductName invalid.");
// Act
@@ -837,15 +835,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary["Product"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["Product"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
- dictionary["Product.Detail1"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Product.Detail1"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Product.Detail1", "Product Detail1 invalid.");
- dictionary["Product.Detail1.Name"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Product.Detail1.Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Product.Detail1.Name", "Product Detail1 Name invalid.");
- dictionary["Product.Detail1Name"] = new ModelState { ValidationState = ModelValidationState.Skipped };
+ dictionary["Product.Detail1Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Skipped };
// Act
dictionary.ClearValidationState("Product.Detail1");
@@ -867,15 +865,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary["Property1"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["Property1"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
- dictionary["Property2"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Property2"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Property2", "Property2 invalid.");
- dictionary["Property3"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Property3"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Property3", "Property invalid.");
- dictionary["Property4"] = new ModelState { ValidationState = ModelValidationState.Skipped };
+ dictionary["Property4"] = new ModelStateEntry { ValidationState = ModelValidationState.Skipped };
// Act
dictionary.ClearValidationState(modelKey);
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ModelBindingHelperTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ModelBindingHelperTest.cs
index 9027f6d32c..cd5b511a5c 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ModelBindingHelperTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ModelBindingHelperTest.cs
@@ -715,12 +715,12 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var metadataProvider = new EmptyModelMetadataProvider();
var dictionary = new ModelStateDictionary();
- dictionary["Name"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Name", "MyProperty invalid.");
- dictionary["Id"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["Id"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("Id", "Id invalid.");
dictionary.AddModelError("Id", "Id is required.");
- dictionary["Category"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["Category"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
// Act
ModelBindingHelper.ClearValidationStateForModel(
@@ -746,16 +746,16 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var metadataProvider = new EmptyModelMetadataProvider();
var dictionary = new ModelStateDictionary();
- dictionary["[0].Name"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["[0].Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("[0].Name", "Name invalid.");
- dictionary["[0].Id"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["[0].Id"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("[0].Id", "Id invalid.");
dictionary.AddModelError("[0].Id", "Id required.");
- dictionary["[0].Category"] = new ModelState { ValidationState = ModelValidationState.Valid };
+ dictionary["[0].Category"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
- dictionary["[1].Name"] = new ModelState { ValidationState = ModelValidationState.Valid };
- dictionary["[1].Id"] = new ModelState { ValidationState = ModelValidationState.Valid };
- dictionary["[1].Category"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["[1].Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
+ dictionary["[1].Id"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
+ dictionary["[1].Category"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("[1].Category", "Category invalid.");
// Act
@@ -793,20 +793,20 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
var metadataProvider = new TestModelMetadataProvider();
var dictionary = new ModelStateDictionary();
- dictionary["product.Name"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["product.Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("product.Name", "Name invalid.");
- dictionary["product.Id"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["product.Id"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("product.Id", "Id invalid.");
dictionary.AddModelError("product.Id", "Id required.");
- dictionary["product.Category"] = new ModelState { ValidationState = ModelValidationState.Valid };
- dictionary["product.Category.Name"] = new ModelState { ValidationState = ModelValidationState.Valid };
- dictionary["product.Order[0].Name"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["product.Category"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
+ dictionary["product.Category.Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
+ dictionary["product.Order[0].Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("product.Order[0].Name", "Order name invalid.");
dictionary["product.Order[0].Address.Street"] =
- new ModelState { ValidationState = ModelValidationState.Invalid };
+ new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("product.Order[0].Address.Street", "Street invalid.");
- dictionary["product.Order[1].Name"] = new ModelState { ValidationState = ModelValidationState.Valid };
- dictionary["product.Order[0]"] = new ModelState { ValidationState = ModelValidationState.Invalid };
+ dictionary["product.Order[1].Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
+ dictionary["product.Order[0]"] = new ModelStateEntry { ValidationState = ModelValidationState.Invalid };
dictionary.AddModelError("product.Order[0]", "Order invalid.");
// Act
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/MutableObjectModelBinderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/MutableObjectModelBinderTest.cs
index 1e684bdf3c..1cc8dfe1a1 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/MutableObjectModelBinderTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/MutableObjectModelBinderTest.cs
@@ -809,9 +809,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
Assert.Single(modelStateDictionary);
// Check Age error.
- ModelState modelState;
- Assert.True(modelStateDictionary.TryGetValue("theModel.Age", out modelState));
- var modelError = Assert.Single(modelState.Errors);
+ ModelStateEntry entry;
+ Assert.True(modelStateDictionary.TryGetValue("theModel.Age", out entry));
+ var modelError = Assert.Single(entry.Errors);
Assert.Null(modelError.Exception);
Assert.NotNull(modelError.ErrorMessage);
Assert.Equal("A value for the 'Age' property was not provided.", modelError.ErrorMessage);
@@ -859,9 +859,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
Assert.Single(modelStateDictionary);
// Check Age error.
- ModelState modelState;
- Assert.True(modelStateDictionary.TryGetValue("theModel.Age", out modelState));
- var modelError = Assert.Single(modelState.Errors);
+ ModelStateEntry entry;
+ Assert.True(modelStateDictionary.TryGetValue("theModel.Age", out entry));
+ var modelError = Assert.Single(entry.Errors);
Assert.Null(modelError.Exception);
Assert.NotNull(modelError.ErrorMessage);
Assert.Equal("A value for the 'Age' property was not provided.", modelError.ErrorMessage);
@@ -914,11 +914,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
Assert.Equal(1, modelStateDictionary.Count);
// Check Age error.
- ModelState modelState;
- Assert.True(modelStateDictionary.TryGetValue("theModel.Age", out modelState));
- Assert.Equal(ModelValidationState.Invalid, modelState.ValidationState);
+ ModelStateEntry entry;
+ Assert.True(modelStateDictionary.TryGetValue("theModel.Age", out entry));
+ Assert.Equal(ModelValidationState.Invalid, entry.ValidationState);
- var modelError = Assert.Single(modelState.Errors);
+ var modelError = Assert.Single(entry.Errors);
Assert.Equal(string.Empty, modelError.ErrorMessage);
Assert.IsType(modelError.Exception);
}
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 0cb44b8ebb..739159583b 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs
@@ -651,9 +651,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
var validator = CreateValidator(new SimpleTypesExcludeFilter());
- modelState.Add("items[0]", new ModelState());
- modelState.Add("items[1]", new ModelState());
- modelState.Add("items[2]", new ModelState());
+ modelState.Add("items[0]", new ModelStateEntry());
+ modelState.Add("items[1]", new ModelStateEntry());
+ modelState.Add("items[2]", new ModelStateEntry());
validationState.Add(model, new ValidationStateEntry()
{
Key = "items",
@@ -698,10 +698,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
{ "BarKey", "BarValue" }
};
- modelState.Add("items[0].Key", new ModelState());
- modelState.Add("items[0].Value", new ModelState());
- modelState.Add("items[1].Key", new ModelState());
- modelState.Add("items[1].Value", new ModelState());
+ modelState.Add("items[0].Key", new ModelStateEntry());
+ modelState.Add("items[0].Value", new ModelStateEntry());
+ modelState.Add("items[1].Key", new ModelStateEntry());
+ modelState.Add("items[1].Value", new ModelStateEntry());
validationState.Add(model, new ValidationStateEntry() { Key = "items" });
// Act
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/SerializableErrorTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/SerializableErrorTests.cs
index e56bdd5768..180923db5d 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/SerializableErrorTests.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/SerializableErrorTests.cs
@@ -72,10 +72,10 @@ namespace Microsoft.AspNet.Mvc
var modelState = new ModelStateDictionary();
modelState.Add(
"key1",
- new ModelState());
+ new ModelStateEntry());
modelState.Add(
"key2",
- new ModelState());
+ new ModelStateEntry());
// Act
var serializableError = new SerializableError(modelState);
diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ModelStateDictionaryExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ModelStateDictionaryExtensionsTest.cs
index cc1200e7a7..923286330b 100644
--- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ModelStateDictionaryExtensionsTest.cs
+++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ModelStateDictionaryExtensionsTest.cs
@@ -155,7 +155,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary.Add("Text", new ModelState());
+ dictionary.Add("Text", new ModelStateEntry());
// Act
dictionary.Remove(model => model.Text);
@@ -169,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary.Add("Child.Text", new ModelState());
+ dictionary.Add("Child.Text", new ModelStateEntry());
// Act
dictionary.Remove(model => model.Child.Text);
@@ -183,7 +183,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
// Arrange
var dictionary = new ModelStateDictionary();
- dictionary.Add("Child.Value", new ModelState());
+ dictionary.Add("Child.Value", new ModelStateEntry());
// Act
dictionary.Remove(model => model.Child.Value);
@@ -198,7 +198,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
// Arrange
var variable = "Test";
var dictionary = new ModelStateDictionary();
- dictionary.Add("variable", new ModelState());
+ dictionary.Add("variable", new ModelStateEntry());
// Act
dictionary.Remove(model => variable);
@@ -211,12 +211,12 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void RemoveAll_ForSingleExpression_RemovesModelStateKeys()
{
// Arrange
- var state = new ModelState();
+ var state = new ModelStateEntry();
var dictionary = new ModelStateDictionary();
dictionary.Add("Key", state);
- dictionary.Add("Text", new ModelState());
- dictionary.Add("Text.Length", new ModelState());
+ dictionary.Add("Text", new ModelStateEntry());
+ dictionary.Add("Text.Length", new ModelStateEntry());
// Act
dictionary.RemoveAll(model => model.Text);
@@ -232,12 +232,12 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void RemoveAll_ForRelationExpression_RemovesModelStateKeys()
{
// Arrange
- var state = new ModelState();
+ var state = new ModelStateEntry();
var dictionary = new ModelStateDictionary();
dictionary.Add("Key", state);
- dictionary.Add("Child", new ModelState());
- dictionary.Add("Child.Text", new ModelState());
+ dictionary.Add("Child", new ModelStateEntry());
+ dictionary.Add("Child.Text", new ModelStateEntry());
// Act
dictionary.RemoveAll(model => model.Child);
@@ -253,11 +253,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void RemoveAll_ForImplicitlyCastedToObjectExpression_RemovesModelStateKeys()
{
// Arrange
- var state = new ModelState();
+ var state = new ModelStateEntry();
var dictionary = new ModelStateDictionary();
dictionary.Add("Child", state);
- dictionary.Add("Child.Value", new ModelState());
+ dictionary.Add("Child.Value", new ModelStateEntry());
// Act
dictionary.RemoveAll(model => model.Child.Value);
@@ -274,13 +274,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
// Arrange
var variable = "Test";
- var state = new ModelState();
+ var state = new ModelStateEntry();
var dictionary = new ModelStateDictionary();
dictionary.Add("Key", state);
- dictionary.Add("variable", new ModelState());
- dictionary.Add("variable.Text", new ModelState());
- dictionary.Add("variable.Value", new ModelState());
+ dictionary.Add("variable", new ModelStateEntry());
+ dictionary.Add("variable.Text", new ModelStateEntry());
+ dictionary.Add("variable.Value", new ModelStateEntry());
// Act
dictionary.RemoveAll(model => variable);
@@ -296,14 +296,14 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
public void RemoveAll_ForModelExpression_RemovesModelPropertyKeys()
{
// Arrange
- var state = new ModelState();
+ var state = new ModelStateEntry();
var dictionary = new ModelStateDictionary();
dictionary.Add("Key", state);
- dictionary.Add("Text", new ModelState());
- dictionary.Add("Child", new ModelState());
- dictionary.Add("Child.Text", new ModelState());
- dictionary.Add("Child.NoValue", new ModelState());
+ dictionary.Add("Text", new ModelStateEntry());
+ dictionary.Add("Child", new ModelStateEntry());
+ dictionary.Add("Child.Text", new ModelStateEntry());
+ dictionary.Add("Child.NoValue", new ModelStateEntry());
// Act
dictionary.RemoveAll(model => model);
diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayTextTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayTextTest.cs
index 5ecb1fb507..ec1d2d954f 100644
--- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayTextTest.cs
+++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperDisplayTextTest.cs
@@ -260,7 +260,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
viewData["FieldPrefix.Name"] = "View data dictionary value";
viewData.TemplateInfo.HtmlFieldPrefix = "FieldPrefix";
- var modelState = new ModelState();
+ var modelState = new ModelStateEntry();
modelState.RawValue = new string[] { "Attempted name value" };
modelState.AttemptedValue = "Attempted name value";
viewData.ModelState["FieldPrefix.Name"] = modelState;
@@ -285,7 +285,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
viewData["Name"] = "View data dictionary value";
viewData.TemplateInfo.HtmlFieldPrefix = "FieldPrefix";
- var modelState = new ModelState();
+ var modelState = new ModelStateEntry();
modelState.RawValue = new string[] { "Attempted name value" };
modelState.AttemptedValue = "Attempted name value";
viewData.ModelState["FieldPrefix.Name"] = modelState;
diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperHiddenTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperHiddenTest.cs
index 3455c16074..ecbaf21235 100644
--- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperHiddenTest.cs
+++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperHiddenTest.cs
@@ -362,9 +362,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
idAttributeDotReplacement: "$");
helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix";
helper.ViewData.ModelState.Clear();
- helper.ViewData.ModelState.Add("Property1", GetModelState("modelstate-without-prefix"));
- helper.ViewData.ModelState.Add("MyPrefix.Property1", GetModelState("modelstate-with-prefix"));
- helper.ViewData.ModelState.Add("MyPrefix$Property1", GetModelState("modelstate-with-iddotreplacement"));
+ helper.ViewData.ModelState.Add("Property1", GetModelStateEntry("modelstate-without-prefix"));
+ helper.ViewData.ModelState.Add("MyPrefix.Property1", GetModelStateEntry("modelstate-with-prefix"));
+ helper.ViewData.ModelState.Add("MyPrefix$Property1", GetModelStateEntry("modelstate-with-iddotreplacement"));
// Act
var result = helper.Hidden("Property1", "explicit-value", htmlAttributes: null);
@@ -661,9 +661,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
helper.ViewData.Model.Property1 = "propValue";
helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix";
helper.ViewData.ModelState.Clear();
- helper.ViewData.ModelState.Add("Property1", GetModelState("modelstate-without-prefix"));
- helper.ViewData.ModelState.Add("MyPrefix.Property1", GetModelState("modelstate-with-prefix"));
- helper.ViewData.ModelState.Add("MyPrefix$Property1", GetModelState("modelstate-with-iddotreplacement"));
+ helper.ViewData.ModelState.Add("Property1", GetModelStateEntry("modelstate-without-prefix"));
+ helper.ViewData.ModelState.Add("MyPrefix.Property1", GetModelStateEntry("modelstate-with-prefix"));
+ helper.ViewData.ModelState.Add("MyPrefix$Property1", GetModelStateEntry("modelstate-with-iddotreplacement"));
// Act
var result = helper.HiddenFor(m => m.Property1, htmlAttributes: null);
@@ -803,9 +803,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
{
// Arrange
var viewData = GetViewDataWithNullModelAndNonNullViewData();
- viewData.ModelState.Add("pre.Property3[key]", GetModelState("Prop3Val"));
- viewData.ModelState.Add("pre.Property4.Property5", GetModelState("Prop5Val"));
- viewData.ModelState.Add("pre.Property4.Property6[0]", GetModelState("Prop6Val"));
+ viewData.ModelState.Add("pre.Property3[key]", GetModelStateEntry("Prop3Val"));
+ viewData.ModelState.Add("pre.Property4.Property5", GetModelStateEntry("Prop5Val"));
+ viewData.ModelState.Add("pre.Property4.Property6[0]", GetModelStateEntry("Prop6Val"));
var helper = DefaultTemplatesUtilities.GetHtmlHelper(viewData);
viewData.TemplateInfo.HtmlFieldPrefix = "pre";
@@ -858,7 +858,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{
var viewData = GetViewDataWithNonNullModel();
viewData["Property1"] = "view-data-val";
- viewData.ModelState.Add("Property1", GetModelState("ModelStateValue"));
+ viewData.ModelState.Add("Property1", GetModelStateEntry("ModelStateValue"));
return viewData;
}
@@ -871,9 +871,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
return viewData;
}
- private static ModelState GetModelState(string value)
+ private static ModelStateEntry GetModelStateEntry(string value)
{
- return new ModelState
+ return new ModelStateEntry
{
RawValue = new string[] { value },
AttemptedValue = value,
diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPasswordTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPasswordTest.cs
index fba8f5efdf..6b3472d2fb 100644
--- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPasswordTest.cs
+++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperPasswordTest.cs
@@ -325,9 +325,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
{
// Arrange
var viewData = GetViewDataWithModelStateAndModelAndViewDataValues();
- viewData.ModelState.Add("pre.Property3[key]", GetModelState("Property3Val"));
- viewData.ModelState.Add("pre.Property4.Property5", GetModelState("Property5Val"));
- viewData.ModelState.Add("pre.Property4.Property6[0]", GetModelState("Property6Val"));
+ viewData.ModelState.Add("pre.Property3[key]", GetModelStateEntry("Property3Val"));
+ viewData.ModelState.Add("pre.Property4.Property5", GetModelStateEntry("Property5Val"));
+ viewData.ModelState.Add("pre.Property4.Property6[0]", GetModelStateEntry("Property6Val"));
viewData["pre.Property3[key]"] = "vdd-value1";
viewData["pre.Property4.Property5"] = "vdd-value2";
viewData["pre.Property4.Property6[0]"] = "vdd-value3";
@@ -358,7 +358,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
{
var viewData = GetViewDataWithNullModelAndNonEmptyViewData();
viewData.Model = new PasswordModel();
- viewData.ModelState.Add("Property1", GetModelState("ModelStateValue"));
+ viewData.ModelState.Add("Property1", GetModelStateEntry("ModelStateValue"));
return viewData;
}
@@ -371,9 +371,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
return viewData;
}
- private static ModelState GetModelState(string value)
+ private static ModelStateEntry GetModelStateEntry(string value)
{
- return new ModelState
+ return new ModelStateEntry
{
RawValue = new string[] { value },
AttemptedValue = value,
diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs
index 81b9b0baae..6da5f15d92 100644
--- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs
+++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperSelectTest.cs
@@ -414,12 +414,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
var modelState = new ModelStateDictionary
{
- ["Property1"] = new ModelState
+ ["Property1"] = new ModelStateEntry
{
RawValue = new string[] { SelectSources.ModelStateEntry.ToString() },
AttemptedValue = SelectSources.ModelStateEntry.ToString()
},
- ["Prefix.Property1"] = new ModelState
+ ["Prefix.Property1"] = new ModelStateEntry
{
RawValue = new string[] { SelectSources.ModelStateEntryWithPrefix.ToString() },
AttemptedValue = SelectSources.ModelStateEntryWithPrefix.ToString()
@@ -455,12 +455,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
var modelState = new ModelStateDictionary
{
- ["Property1"] = new ModelState
+ ["Property1"] = new ModelStateEntry
{
RawValue = new string[] { SelectSources.ModelStateEntry.ToString() },
AttemptedValue = SelectSources.ModelStateEntry.ToString()
},
- ["Prefix.Property1"] = new ModelState
+ ["Prefix.Property1"] = new ModelStateEntry
{
RawValue = new string[] { SelectSources.ModelStateEntryWithPrefix.ToString() },
AttemptedValue = SelectSources.ModelStateEntryWithPrefix.ToString()
@@ -825,12 +825,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
var modelState = new ModelStateDictionary
{
- ["Property1"] = new ModelState
+ ["Property1"] = new ModelStateEntry
{
RawValue = new string[] { SelectSources.ModelStateEntry.ToString() },
AttemptedValue = SelectSources.ModelStateEntry.ToString()
},
- ["Prefix.Property1"] = new ModelState
+ ["Prefix.Property1"] = new ModelStateEntry
{
RawValue = new string[] { SelectSources.ModelStateEntryWithPrefix.ToString() },
AttemptedValue = SelectSources.ModelStateEntryWithPrefix.ToString()
@@ -866,12 +866,12 @@ namespace Microsoft.AspNet.Mvc.Rendering
var modelState = new ModelStateDictionary
{
- ["Property1"] = new ModelState
+ ["Property1"] = new ModelStateEntry
{
RawValue = new string[] { SelectSources.ModelStateEntry.ToString() },
AttemptedValue = SelectSources.ModelStateEntry.ToString()
},
- ["Prefix.Property1"] = new ModelState
+ ["Prefix.Property1"] = new ModelStateEntry
{
RawValue = new string[] { SelectSources.ModelStateEntryWithPrefix.ToString() },
AttemptedValue = SelectSources.ModelStateEntryWithPrefix.ToString()
diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValueTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValueTest.cs
index 34b3c085bc..4f8ba5196a 100644
--- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValueTest.cs
+++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/Rendering/HtmlHelperValueTest.cs
@@ -163,12 +163,12 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
viewData["StringProperty"] = "ViewDataValue";
viewData.TemplateInfo.HtmlFieldPrefix = "FieldPrefix";
- var modelState = new ModelState();
+ var modelState = new ModelStateEntry();
modelState.AttemptedValue = "StringPropertyAttemptedValue";
modelState.RawValue = new string[] { "StringPropertyRawValue" };
viewData.ModelState["FieldPrefix.StringProperty"] = modelState;
- modelState = new ModelState();
+ modelState = new ModelStateEntry();
modelState.AttemptedValue = "ModelAttemptedValue";
modelState.RawValue = new string[] { "ModelRawValue" };
viewData.ModelState["FieldPrefix"] = modelState;
@@ -220,7 +220,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
var viewData = helper.ViewData;
viewData["StringProperty"] = "ViewDataValue <\"\">";
- var modelState = new ModelState();
+ var modelState = new ModelStateEntry();
modelState.AttemptedValue = "ObjectPropertyAttemptedValue <\"\">";
modelState.RawValue = new string[] { "ObjectPropertyRawValue <\"\">" };
viewData.ModelState["ObjectProperty"] = modelState;
diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs
index d01dcb4478..5d698eddcb 100644
--- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs
+++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs
@@ -33,7 +33,12 @@ namespace System.Web.Http.Dispatcher
yield return new[] { new HttpError() };
yield return new[] { new HttpError("error") };
yield return new[] { new HttpError(new NotImplementedException(), true) };
- yield return new[] { new HttpError(new ModelStateDictionary() { { "key", new ModelState() { Errors = { new ModelError("error") } } } }, true) };
+ yield return new[] { new HttpError(
+ new ModelStateDictionary()
+ {
+ { "key", new ModelStateEntry { Errors = { new ModelError("error") } } }
+ },
+ true) };
}
}