protected void InitializeValidators() { MockedValidator = new Mock <IMessageValidator <Message> >(); MockedDependencyContainer .Setup(method => method.GetAllInstances <IMessageValidator <Message> >()) .Returns(() => new [] { MockedValidator.Object }); }
public void ShouldNotThrowException_WhenMultipleHandlersForPublication() { MockedDependencyContainer .Setup(method => method.GetAllInstances <IHandler <Publication> >()) .Returns(() => new [] { MockedPublicationHandler.Object, MockedPublicationHandler.Object }); Should .NotThrow(() => Dispatcher.GetHandlers <IHandler <Publication> >()); }
public async void ShouldHandleMany_WhenDispatchPublicationWithoutResult() { MockedDependencyContainer .Setup(method => method.GetAllInstances <ICancellableAsyncHandler <Publication> >()) .Returns(() => new [] { MockedCancellableAsyncPublicationHandler.Object, MockedCancellableAsyncPublicationHandler.Object }); await Dispatcher.DispatchAsync(Publication, CancellationToken); MockedCancellableAsyncPublicationHandler.Verify(x => x.HandleAsync(Publication, CancellationToken), Times.Exactly(2)); }
public void ShouldHandleMany_WhenDispatchPublication() { MockedDependencyContainer .Setup(method => method.GetAllInstances <IHandler <Publication> >()) .Returns(() => new [] { MockedPublicationHandler.Object, MockedPublicationHandler.Object }); Dispatcher.Dispatch(Publication); MockedPublicationHandler.Verify(x => x.Handle(Publication), Times.Exactly(2)); }
private void InitializeDependencies() { MockedDependencyContainer .Setup(method => method.GetAllInstances <IHandler <Message, Result> >()) .Returns(() => new[] { MockedHandler.Object }); MockedDependencyContainer .Setup(method => method.GetAllInstances <IHandler <Message> >()) .Returns(() => new[] { MockedFireAndForgetHandler.Object }); MockedDependencyContainer .Setup(method => method.GetAllInstances <IAsyncHandler <Message, Result> >()) .Returns(() => new[] { MockedAsyncHandler.Object }); MockedDependencyContainer .Setup(method => method.GetAllInstances <IAsyncHandler <Message> >()) .Returns(() => new[] { MockedAsyncFireAndForgetHandler.Object }); MockedDependencyContainer .Setup(method => method.GetAllInstances <ICancellableAsyncHandler <Message, Result> >()) .Returns(() => new[] { MockedCancellableAsyncHandler.Object }); MockedDependencyContainer .Setup(method => method.GetAllInstances <ICancellableAsyncHandler <Message> >()) .Returns(() => new[] { MockedCancellableAsyncFireAndForgetHandler.Object }); }
protected void ClearMockedDependencies() { MockedDependencyContainer .Setup(method => method.GetAllInstances <IHandler <Message, Result> >()) .Returns(() => new IHandler <Message, Result> [0]); MockedDependencyContainer .Setup(method => method.GetAllInstances <IHandler <Message> >()) .Returns(() => new IHandler <Message> [0]); MockedDependencyContainer .Setup(method => method.GetAllInstances <IAsyncHandler <Message, Result> >()) .Returns(() => new IAsyncHandler <Message, Result> [0]); MockedDependencyContainer .Setup(method => method.GetAllInstances <IAsyncHandler <Message> >()) .Returns(() => new IAsyncHandler <Message> [0]); MockedDependencyContainer .Setup(method => method.GetAllInstances <ICancellableAsyncHandler <Message, Result> >()) .Returns(() => new ICancellableAsyncHandler <Message, Result> [0]); MockedDependencyContainer .Setup(method => method.GetAllInstances <ICancellableAsyncHandler <Message> >()) .Returns(() => new ICancellableAsyncHandler <Message> [0]); }