Skip to content

Commit

Permalink
Merge pull request #84 from marcwittke/release/6.0.0
Browse files Browse the repository at this point in the history
test waiting improved
  • Loading branch information
marcwittke committed Oct 8, 2019
2 parents d815f78 + d3883bd commit bf1a057
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public DynamicEventHandler(IIntegrationEventHandler integrationEventHandlerImple
public void Handle(dynamic eventData)
{
_integrationEventHandlerImplementation.Handle(eventData);
eventData.Processed.Set();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void CallsMixedEventHandlers()
var integrationEvent = new TestIntegrationEvent(34, "gaga");
Sut.Publish(integrationEvent);
ScopeCompleted.WaitOne(Debugger.IsAttached ? int.MaxValue : 5000);
ScopeCompleted.WaitOne(Debugger.IsAttached ? int.MaxValue : 5000); // wait for two scope completions! two events need to be processed

A.CallTo(() => _app.TypedHandler.Handle(A<TestIntegrationEvent>
.That
Expand Down Expand Up @@ -140,11 +141,7 @@ public AFakeApplication(AutoResetEvent scopeCompleted) : this (A.Fake<ICompositi
private AFakeApplication(ICompositionRoot compositionRoot, AutoResetEvent scopeCompleted)
: base(compositionRoot, A.Fake<ITenantIdService>(), A.Fake<IExceptionLogger>())
{
var scope = A.Fake<IDisposable>();
A.CallTo(() => CompositionRoot.BeginScope())
.Returns(scope);

A.CallTo(() => scope.Dispose()).Invokes(() => scopeCompleted.Set());
A.CallTo(() => CompositionRoot.BeginScope()).Returns(new PseudoScope(scopeCompleted));

A.CallTo(() => CompositionRoot.GetInstance(A<Type>.That.IsEqualTo(typeof(TypedEventHandler))))
.Returns(new TypedEventHandler(TypedHandler));
Expand All @@ -161,6 +158,21 @@ private AFakeApplication(ICompositionRoot compositionRoot, AutoResetEvent scopeC
A.CallTo(() => CompositionRoot.GetInstance(A<Type>.That.IsEqualTo(typeof(ThrowingDynamicEventHandler))))
.Returns(new ThrowingDynamicEventHandler());
}

private class PseudoScope : IDisposable
{
private readonly AutoResetEvent _scopeCompleted;

public PseudoScope(AutoResetEvent scopeCompleted)
{
_scopeCompleted = scopeCompleted;
}

public void Dispose()
{
_scopeCompleted.Set();
}
}
}
}
}

0 comments on commit bf1a057

Please sign in to comment.