本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}