public async Task ExecuteDeferredEvents_WhenCalled_ShouldCallAllEventHandlers() { // Arrange var @event = new FakeEvent { Id = 1 }; var handlerFactory = new MessageHandlerRegistry(); var mediator = new Mediator(handlerFactory.MultiInstanceFactory, handlerFactory.SingleInstanceFactory); handlerFactory.AddHandlersForEvent(new List <IEventHandler <FakeEvent> > { _autoSubstitute.SubstituteFor <HandlerDeferringMultipleEvents>(mediator), _autoSubstitute.SubstituteFor <HandlerDeferringSingleEvent>(mediator), _autoSubstitute.SubstituteFor <HandlerWithoutAdditionalEvents>() }); mediator.DeferEvent(@event); // Act await mediator.ExecuteDeferredEvents(); // Assert foreach (var handler in handlerFactory.GetHandlersFor <FakeEvent>()) { handler.Received().Handle(Arg.Any <FakeEvent>()).FireAndForget(); } }
public void Example_test_with_substitute_for_concrete() { const int val1 = 3; const int val2 = 2; const int val3 = 10; var AutoSubstitute = new AutoSubstitute(); AutoSubstitute.Resolve <IDependency2>().SomeOtherMethod().Returns(val1); AutoSubstitute.SubstituteFor <ConcreteClass>(val2).Add(Arg.Any <int>()).Returns(val3); var result = AutoSubstitute.Resolve <MyClassWithConcreteDependency>().AMethod(); Assert.That(result, Is.EqualTo(val3)); }
public virtual void before_each() { autoSubstitute = new AutoSubstitute(); proxyableExecutor = Substitute.For <IProxyableTestExecutor>(); remoteRunner = autoSubstitute.SubstituteFor <ICrossDomainRunner <IProxyableTestExecutor, int> >(); progressRecorder = autoSubstitute.Resolve <IProgressRecorder>(); logger = autoSubstitute.Resolve <IOutputLogger>(); crossDomainLogger = autoSubstitute.Resolve <ICrossDomainLogger>(); executor = autoSubstitute.Resolve <BinaryTestExecutor>(); }
public virtual void before_each() { autoSubstitute = new AutoSubstitute(); proxyableDiscoverer = Substitute.For <IProxyableTestDiscoverer>(); remoteRunner = autoSubstitute.SubstituteFor < ICrossDomainRunner <IProxyableTestDiscoverer, DiscoveredExample[]> >(); fileService = autoSubstitute.Resolve <IFileService>(); logger = autoSubstitute.Resolve <IOutputLogger>(); crossDomainLogger = autoSubstitute.Resolve <ICrossDomainLogger>(); discoverer = autoSubstitute.Resolve <BinaryTestDiscoverer>(); }
public RegisterTest() { _Mapper = AutoSubstitute.SubstituteFor <IMapper>(); }
public void Example_test_with_substitute_for_concrete() { const int val1 = 3; const int val2 = 2; const int val3 = 10; var AutoSubstitute = new AutoSubstitute(); AutoSubstitute.Resolve<IDependency2>().SomeOtherMethod().Returns(val1); AutoSubstitute.SubstituteFor<ConcreteClass>(val2).Add(Arg.Any<int>()).Returns(val3); var result = AutoSubstitute.Resolve<MyClassWithConcreteDependency>().AMethod(); Assert.That(result, Is.EqualTo(val3)); }