Posted on Oct 6, 2014 by
Massive Cat
void Main() { var fooMock = new Mock<IFoo>(); fooMock.Setup(v => v.Foo()).Throws<Exception>();
var tasks = Enumerable.Repeat(0, 20)
.Select(v => new Task(() => fooMock.Object.Foo()))
.ToArray();
foreach (var task in tasks)
{
task.Start();
}
Action waitAllAction = () => Task.WaitAll(tasks);
waitAllAction.ShouldThrow<AggregateException>();
fooMock.Verify(v => v.Foo(), Times.Exactly(20)); //Verification fails
}
// Define other methods and classes here
public interface IFoo { int Foo(); }
Version: 4.2.1402.2112. Os: Win2008
Am I correct that verification should succeed
Status: New
Labels:
Type-Defect
Priority-Medium