01.[Fact]02.public void Reconcile_LocationGroupChangedEvent_ReconcileSuccessfully()03.{04. using (var container = new MockingContainer<Assignment>(settings))05. {06. //Arrange07. container.Arrange<IFacade>(x =>x.Initialize()).OccursAtMost(1);08. 09. //Act10. container.Instance.Reconcile();11. 12. //Assert13. container.AssertAll();14. }15.}16. 17.// Method under test18. 19.public void Reconcile()20.{ 21. Task.Factory.StartNew(() => facade.Initialize());22.}
I am getting intermittent errors when running the above Test. It fails so infrequently that I am unable to debug. When it fails, here is what I see in the logs.
Reconcile_Test [FAIL]System.InvalidOperationException : Collection was modified; enumeration operation may not execute.Stack Trace: at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at System.Linq.Enumerable.<SelectManyIterator>d__23`3.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at Telerik.JustMock.Core.MocksRepository.GetDebugView(Object mock) at Telerik.JustMock.DebugView.<>c.<get_CurrentState>b__1_0() at Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func`1 guardedAction) at Telerik.JustMock.DebugView.TraceEvent(IndentLevel traceLevel, Func`1 message) at Telerik.JustMock.Core.Context.MockingContext.ResolveRepository(UnresolvedContextBehavior unresolvedContextBehavior) at Telerik.JustMock.Helpers.FluentHelper.<>c__DisplayClass13_0`1.<AssertAll>b__0() at Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal(Action guardedAction) at Telerik.JustMock.AutoMock.MockResolver.ForEachMock(Action`1 action) at Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal(Action guardedAction) E:\agt01\COM-CN-JOB1\AssignmentTest.cs(14,0): at AssignmentTest.Reconcile_Test()