示例#1
0
 protected void InitializeValidators()
 {
     MockedValidator = new Mock <IMessageValidator <Message> >();
     MockedDependencyContainer
     .Setup(method => method.GetAllInstances <IMessageValidator <Message> >())
     .Returns(() => new [] { MockedValidator.Object });
 }
示例#2
0
        public void ShouldNotThrowException_WhenMultipleHandlersForPublication()
        {
            MockedDependencyContainer
            .Setup(method => method.GetAllInstances <IHandler <Publication> >())
            .Returns(() => new [] { MockedPublicationHandler.Object, MockedPublicationHandler.Object });

            Should
            .NotThrow(() => Dispatcher.GetHandlers <IHandler <Publication> >());
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
 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 });
 }
示例#6
0
 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]);
 }