本文整理汇总了C#中ValidationResult.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ValidationResult.ToString方法的具体用法?C# ValidationResult.ToString怎么用?C# ValidationResult.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValidationResult
的用法示例。
在下文中一共展示了ValidationResult.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanCreate
public void CanCreate()
{
var validationIssues = new List<ValidationIssue>();
var validationResult = new ValidationResult(validationIssues);
validationResult.ValidationIssues.Should().Be.Equals(validationIssues);
validationResult.HasErrors.Should().Be.False();
validationResult.ToString().Should().Be.EqualTo(string.Empty);
validationIssues.Add(new ValidationIssue("Invalid property", "MyProperty", "NotAValidValue"));
validationResult.HasErrors.Should().Be.True();
validationResult.ToString().Should().Contain("Invalid property");
validationResult.ToString().Should().Contain("MyProperty");
validationResult.ToString().Should().Contain("NotAValidValue");
}
示例2: AddValidationResult
/// <summary>
/// Adds the supplied <see cref="ValidationResult"/> to its current <see cref="ValidationResultCollectionScope"/>.
/// </summary>
/// <param name="result">The supplied <see cref="ValidationResult"/>.</param>
public void AddValidationResult(ValidationResult result)
{
var currentScope = CurrentScope;
currentScope.ValidationResult.Add(result);
LogManager.Log(LogLevel.Informational, result.ToString()); // log validation messages with informational level only for debugging purposes
}
示例3: ValidationException
public ValidationException(ValidationResult validationResult, Exception innerException)
: this(validationResult != null ? validationResult.ToString() : string.Empty, innerException)
{
this.ValidationResult = validationResult;
}
示例4: ToString_ReturnsExpected
public void ToString_ReturnsExpected(string errorMessage, string expected)
{
ValidationResult validationResult = new ValidationResult(errorMessage);
Assert.Equal(expected, validationResult.ToString());
}
示例5: ValidationResult_ToString_ErrorMessage_Empty
public void ValidationResult_ToString_ErrorMessage_Empty() {
ValidationResult result = new ValidationResult(string.Empty);
Assert.AreEqual(string.Empty, result.ToString());
}
示例6: ValidationResult_ToString_ErrorMessage_Null
public void ValidationResult_ToString_ErrorMessage_Null() {
ValidationResult result = new ValidationResult(null);
Assert.AreEqual(typeof(ValidationResult).FullName, result.ToString());
}
示例7: ValidationResult_ToString_ErrorMessage_Specified
public void ValidationResult_ToString_ErrorMessage_Specified() {
string message = "This is the error message";
ValidationResult result = new ValidationResult(message);
Assert.AreEqual(message, result.ToString());
}