Whenever I run either of the following unit test with a debugger attached, I get a VerificationException
inside FluentValidation code at this point (will post whole stacktrace later if necessary):
at FluentValidation.Resources.LocalizedStringSource.CreateFromExpression(Expression`1 expression, IResourceAccessorBuilder resourceProviderSelectionStrategy)
in ...\FluentValidation\Resources\LocalizedStringSource.cs:line 66
The tests are:
using FluentValidation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var c = new MyClass();
var v = new MyValidator();
v.Validate(c);
}
[TestMethod]
public void TestMethod2()
{
Exception ex = null;
var done = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(
o =>
{
try
{
TestMethod1();
}
catch (Exception e)
{
ex = e;
}
finally
{
done.Set();
}
});
done.WaitOne();
Assert.IsNull(ex);
}
}
public class MyValidator : AbstractValidator<MyClass>
{
public MyValidator()
{
RuleFor(c => c.MyProperty).GreaterThan(0);
}
}
public class MyClass
{
public int MyProperty { get; set; }
}
I've referenced just these assemblies in a single-solution, single-project scenario, targeting the 4.0.30319 runtime:
- FluentValidation v3.0.0.0
- Microsoft.VisualStudio.QualityTools.UnitTestFramework v10.0.0.0
- System
- System.Core
Some other points:
- Running the test without a debugger works fine
- Code coverage is turned off
- I've minimized the referenced assemblies down to the minimum
- I don't see any errors in the Fusion log
- I tried applying the
SecurityRulesAttribute
from the answer to a similar question - I tried some things from a blog post on VerificationException and testing
- Occurs under both MSTest and Resharper hosts (haven't tried NUnit, because the common thread seems to be 'under debugger'.
- Occurs when running VS as admin or non-admin
Does anyone know how I can prevent this VerificationException
, work around it, and/or why it's being caused? It seems with so few assemblies, there shouldn't be any conflicting ones loading. I've also moved the FluentValidation satellite assemblies out of the way but still get the exception.