The following test fails when run via nCrunch, but succeeds (as it should) when run via the VS Test Explorer:
Quote:
using Xunit;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
namespace ncrunchRepo
{
public class Class1
{
[Fact]
public void Bad()
{
var result = Test(new TestClass { Email = "bad@example.com2" });
Assert.NotEmpty(result);
}
private List<ValidationResult> Test(TestClass @object)
{
var context = new ValidationContext(@object, serviceProvider: null, items: null);
var results = new List<ValidationResult>();
Validator.TryValidateObject(
@object, context, results,
validateAllProperties: true
);
return results;
}
}
public class TestClass
{
[EmailAddress]
public string Email { get; set; }
}
}
This fails under both net472 and netcoreapp2.0, althought I assume it'll fail under older versions too.
Any idea what might cause this? I've checked the Debug modules window and the same
C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll
is loaded under both circumstances, which I believe is what is ultimatly doing the Validation here.
Thanks