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


C# ActivityType.ValidationResults方法代码示例

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


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

示例1: ActivityTypeDoesNotSaveWithIndicatorWith1Character

        public void ActivityTypeDoesNotSaveWithIndicatorWith1Character()
        {
            //Invalid Indicator
            var activityType = new ActivityType
            {
                ActivityCategory = ActivityCategory,
                Indicator = "1",
                Name = ValidValueName
            };

            try
            {
                using (var ts = new TransactionScope())
                {
                    _activityTypeRepository.EnsurePersistent(activityType);

                    ts.CommitTransaction();
                }
            }
            catch (Exception)
            {
                var results = activityType.ValidationResults().AsMessageList();
                Assert.AreEqual(1, results.Count);
                results.AssertContains("Indicator: length must be between 2 and 2");
                //Assert.AreEqual("Object of type FSNEP.Core.Domain.ActivityType could not be persisted\n\n\r\nValidation Errors: Indicator, The length of the value must fall within the range \"2\" (Inclusive) - \"2\" (Inclusive).\r\n", message.Message, "Expected Exception Not encountered");
                throw;
            }
        }
开发者ID:ucdavis,项目名称:FSNEP,代码行数:28,代码来源:ActivityTypeRepositiryTests.cs

示例2: ActivityTypeDoesNotSaveWithNullName

        public void ActivityTypeDoesNotSaveWithNullName()
        {
            //ServiceLocatorInitializer.Init();
            var activityType = new ActivityType
            {
                ActivityCategory = ActivityCategory,
                Indicator = ValidValueIndicator,
                Name = null
            };

            try
            {
                using (var ts = new TransactionScope())
                {
                    _activityTypeRepository.EnsurePersistent(activityType);

                    ts.CommitTransaction();
                }
            }
            catch (Exception)
            {
                var results = activityType.ValidationResults().AsMessageList();
                Assert.AreEqual(1, results.Count);
                results.AssertContains("Name: may not be null or empty");
                //results.AssertContains("Name: length must be between 0 and 50");
                //Assert.AreEqual("Object of type FSNEP.Core.Domain.ActivityType could not be persisted\n\n\r\nValidation Errors: Name, The value cannot be null.\r\nName, length must be between 0 and 50\r\n", message.Message, "Expected Exception Not encountered");
                throw;
            }
        }
开发者ID:ucdavis,项目名称:FSNEP,代码行数:29,代码来源:ActivityTypeRepositiryTests.cs

示例3: CanNotSaveWithSpacesOnlyInIndicator

        public void CanNotSaveWithSpacesOnlyInIndicator()
        {
            var activityType = new ActivityType
            {
                ActivityCategory = ActivityCategory,
                Indicator = "  ",
                Name = ValidValueName
            };

            try
            {
                using (var ts = new TransactionScope())
                {
                    _activityTypeRepository.EnsurePersistent(activityType);

                    ts.CommitTransaction();
                }

            }
            catch (Exception)
            {
                var results = activityType.ValidationResults().AsMessageList();
                Assert.AreEqual(1, results.Count);
                results.AssertContains("Indicator: may not be null or empty");
                throw;
            }
        }
开发者ID:ucdavis,项目名称:FSNEP,代码行数:27,代码来源:ActivityTypeRepositiryTests.cs

示例4: ActivityTypeDoesNotSaveWithNullActivityCategory

        public void ActivityTypeDoesNotSaveWithNullActivityCategory()
        {
            var activityType = new ActivityType
            {
                ActivityCategory = null,
                Indicator = ValidValueIndicator,
                Name = ValidValueName
            };

            try
            {
                using (var ts = new TransactionScope())
                {
                    _activityTypeRepository.EnsurePersistent(activityType);

                    ts.CommitTransaction();
                }
            }
            catch (Exception)
            {
                var results = activityType.ValidationResults().AsMessageList();
                Assert.AreEqual(1, results.Count);
                results.AssertContains("ActivityCategory: may not be null");
                //Assert.AreEqual("Object of type FSNEP.Core.Domain.ActivityType could not be persisted\n\n\r\nValidation Errors: ActivityCategory, The value cannot be null.\r\n", message.Message, "Expected Exception Not encountered");
                throw;
            }
        }
开发者ID:ucdavis,项目名称:FSNEP,代码行数:27,代码来源:ActivityTypeRepositiryTests.cs


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