当前位置: 首页>>代码示例>>C#>>正文


C# ModelStateDictionary.GetFieldValidationState方法代码示例

本文整理汇总了C#中ModelStateDictionary.GetFieldValidationState方法的典型用法代码示例。如果您正苦于以下问题:C# ModelStateDictionary.GetFieldValidationState方法的具体用法?C# ModelStateDictionary.GetFieldValidationState怎么用?C# ModelStateDictionary.GetFieldValidationState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelStateDictionary的用法示例。


在下文中一共展示了ModelStateDictionary.GetFieldValidationState方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFieldValidationState_ReturnsUnvalidatedIfDictionaryDoesNotContainKey

        public void GetFieldValidationState_ReturnsUnvalidatedIfDictionaryDoesNotContainKey()
        {
            // Arrange
            var msd = new ModelStateDictionary();

            // Act
            var validationState = msd.GetFieldValidationState("foo");

            // Assert
            Assert.Equal(ModelValidationState.Unvalidated, validationState);
        }
开发者ID:Nakro,项目名称:Mvc,代码行数:11,代码来源:ModelStateDictionaryTest.cs

示例2: GetFieldValidationState_ReturnsInvalidIfKeyChildContainsErrors

        public void GetFieldValidationState_ReturnsInvalidIfKeyChildContainsErrors()
        {
            // Arrange
            var msd = new ModelStateDictionary();
            msd.AddModelError("foo.bar", "error text");

            // Act
            var validationState = msd.GetFieldValidationState("foo");

            // Assert
            Assert.Equal(ModelValidationState.Invalid, validationState);
        }
开发者ID:Nakro,项目名称:Mvc,代码行数:12,代码来源:ModelStateDictionaryTest.cs

示例3: GetFieldValidity_ReturnsValid_IfAllKeysAreValid

        public void GetFieldValidity_ReturnsValid_IfAllKeysAreValid()
        {
            // Arrange
            var dictionary = new ModelStateDictionary();
            dictionary["user.Address"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
            dictionary["user.Name"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };

            // Act
            var validationState = dictionary.GetFieldValidationState("user");

            // Assert
            Assert.Equal(ModelValidationState.Valid, validationState);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:13,代码来源:ModelStateDictionaryTest.cs

示例4: GetFieldValidity_ReturnsInvalid_IfAllKeysAreValidatedAndAnyEntryIsInvalid

        public void GetFieldValidity_ReturnsInvalid_IfAllKeysAreValidatedAndAnyEntryIsInvalid(string key)
        {
            // Arrange
            var dictionary = new ModelStateDictionary();
            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 ModelStateEntry { ValidationState = ModelValidationState.Valid };
            dictionary["[0].product.Age[0]"] = new ModelStateEntry { ValidationState = ModelValidationState.Valid };
            dictionary.AddModelError("[1].product.Name", "Name is invalid");

            // Act
            var validationState = dictionary.GetFieldValidationState(key);

            // Assert
            Assert.Equal(ModelValidationState.Invalid, validationState);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:17,代码来源:ModelStateDictionaryTest.cs

示例5: GetFieldValidity_ReturnsUnvalidated_IfAnyItemInSubtreeIsInvalid

        public void GetFieldValidity_ReturnsUnvalidated_IfAnyItemInSubtreeIsInvalid()
        {
            // Arrange
            var dictionary = new ModelStateDictionary();
            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");

            // Act
            var validationState = dictionary.GetFieldValidationState("user");

            // Assert
            Assert.Equal(ModelValidationState.Unvalidated, validationState);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:14,代码来源:ModelStateDictionaryTest.cs

示例6: GetFieldValidity_ReturnsUnvalidated_IfNoEntryExistsForKey

        public void GetFieldValidity_ReturnsUnvalidated_IfNoEntryExistsForKey()
        {
            // Arrange
            var dictionary = new ModelStateDictionary();
            dictionary.SetModelValue("user.Name", new string[] { "some value" }, "some value");

            // Act
            var validationState = dictionary.GetFieldValidationState("not-user");

            // Assert
            Assert.Equal(ModelValidationState.Unvalidated, validationState);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:12,代码来源:ModelStateDictionaryTest.cs

示例7: GetFieldValidationState_IndexedPrefix_ReturnsValidIfModelStateDoesNotContainErrors

        public void GetFieldValidationState_IndexedPrefix_ReturnsValidIfModelStateDoesNotContainErrors(string key)
        {
            // Arrange
            var validState = new ModelStateEntry
            {
                ValidationState = ModelValidationState.Valid
            };
            var dictionary = new ModelStateDictionary
            {
                { key, validState }
            };

            // Act
            var validationState = dictionary.GetFieldValidationState("[0].foo");

            // Assert
            Assert.Equal(ModelValidationState.Valid, validationState);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:18,代码来源:ModelStateDictionaryTest.cs

示例8: GetFieldValidationState_IndexedPrefix_ReturnsInvalidIfKeyChildContainsErrors

        public void GetFieldValidationState_IndexedPrefix_ReturnsInvalidIfKeyChildContainsErrors(string key)
        {
            // Arrange
            var dictionary = new ModelStateDictionary();
            dictionary.AddModelError(key, "error text");

            // Act
            var validationState = dictionary.GetFieldValidationState("[0].foo");

            // Assert
            Assert.Equal(ModelValidationState.Invalid, validationState);
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:12,代码来源:ModelStateDictionaryTest.cs

示例9: GetFieldValidationState_IndexedPrefix_ReturnsValidIfModelStateDoesNotContainErrors

        public void GetFieldValidationState_IndexedPrefix_ReturnsValidIfModelStateDoesNotContainErrors(string key)
        {
            // Arrange
            var validState = new ModelState
            {
                Value = new ValueProviderResult(null, null, null),
                ValidationState = ModelValidationState.Valid
            };
            var msd = new ModelStateDictionary
            {
                { key, validState }
            };

            // Act
            var validationState = msd.GetFieldValidationState("[0].foo");

            // Assert
            Assert.Equal(ModelValidationState.Valid, validationState);
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:19,代码来源:ModelStateDictionaryTest.cs

示例10: GetFieldValidationState_ReturnsValidIfModelStateDoesNotContainErrors

        public void GetFieldValidationState_ReturnsValidIfModelStateDoesNotContainErrors(string key)
        {
            // Arrange
            var validState = new ModelState
            {
                ValidationState = ModelValidationState.Valid
            };
            var msd = new ModelStateDictionary
            {
                { key, validState }
            };

            // Act
            var validationState = msd.GetFieldValidationState("foo");

            // Assert
            Assert.Equal(ModelValidationState.Valid, validationState);
        }
开发者ID:4myBenefits,项目名称:Mvc,代码行数:18,代码来源:ModelStateDictionaryTest.cs

示例11: GetFieldValidity_ReturnsInvalid_IfAllKeysAreValidatedAndAnyEntryIsInvalid_Collection

        public void GetFieldValidity_ReturnsInvalid_IfAllKeysAreValidatedAndAnyEntryIsInvalid_Collection(string key)
        {
            // Arrange
            var dictionary = new ModelStateDictionary();
            dictionary.MarkFieldValid("[0].product.Name");
            dictionary.MarkFieldValid("[0].product.Age[0]");
            dictionary.AddModelError("[0].product.Name", "Name is invalid");

            // Act
            var validationState = dictionary.GetFieldValidationState(key);

            // Assert
            Assert.Equal(ModelValidationState.Invalid, validationState);
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:14,代码来源:ModelStateDictionaryTest.cs

示例12: GetFieldValidity_ReturnsInvalid_IfAllKeysAreValidatedAndAnyEntryIsInvalid

        public void GetFieldValidity_ReturnsInvalid_IfAllKeysAreValidatedAndAnyEntryIsInvalid(string key)
        {
            // Arrange
            var dictionary = new ModelStateDictionary();
            dictionary.MarkFieldValid("user.Address");
            dictionary.MarkFieldValid("user.Name");
            dictionary.AddModelError("user.Age", "Age is not a valid int");

            // Act
            var validationState = dictionary.GetFieldValidationState(key);

            // Assert
            Assert.Equal(ModelValidationState.Invalid, validationState);
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:14,代码来源:ModelStateDictionaryTest.cs

示例13: GetFieldValidationState_ReturnsValidIfModelStateDoesNotContainErrors

        public void GetFieldValidationState_ReturnsValidIfModelStateDoesNotContainErrors(string key)
        {
            // Arrange
            var dictionary = new ModelStateDictionary();
            dictionary.MarkFieldValid(key);

            // Act
            var validationState = dictionary.GetFieldValidationState("foo");

            // Assert
            Assert.Equal(ModelValidationState.Valid, validationState);
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:12,代码来源:ModelStateDictionaryTest.cs


注:本文中的ModelStateDictionary.GetFieldValidationState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。