public async Task When_used_to_test_another_component_collects_outgoing_events()
        {
            var uniformSession    = new TestableUniformSession();
            var reusableComponent = new ReusableComponent(uniformSession);

            await reusableComponent.PublishEvent();

            Assert.AreEqual(1, uniformSession.PublishedMessages.Length);
        }
Ejemplo n.º 2
0
 void TheTest()
 {
     #region UniformSessionSagaTesting
     var session = new TestableUniformSession();
     var saga    = new SomeSaga(session);
     Test.Saga(saga)
     .WithUniformSession(session)
     .ExpectPublish <SomeEvent>()
     .WhenHandling <SomeCommand>();
     #endregion
 }
Ejemplo n.º 3
0
    void TheTest()
    {
        #region UniformSessionServiceTesting
        var session     = new TestableUniformSession();
        var someService = new SomeService(session);

        someService.DoTheThing();

        Assert.AreEqual(1, session.SentMessages.Length);
        #endregion
    }
Ejemplo n.º 4
0
    void TheTest()
    {
        #region UniformSessionHandlerTesting
        var session = new TestableUniformSession();
        var handler = new SomeMessageHandler(session);

        Test.Handler(handler)
            .WithUniformSession(session)
            .ExpectPublish<SomeEvent>()
            .OnMessage<SomeMessage>();
        #endregion
    }
        public async Task Shares_state_with_message_session()
        {
            var messageSession = new TestableMessageSession();
            var uniformSession = new TestableUniformSession(messageSession);
            var component      = new MessageSessionComponent(uniformSession);

            await component.DoSomething(messageSession);

            Assert.AreEqual(2, uniformSession.PublishedMessages.Length);
            Assert.AreEqual(2, uniformSession.SentMessages.Length);
            Assert.AreEqual(2, messageSession.PublishedMessages.Length);
            Assert.AreEqual(2, messageSession.SentMessages.Length);
        }
        public async Task Shares_state_with_pipeline_context()
        {
            var pipelineContext = new TestableIncomingLogicalMessageContext();
            var uniformSession  = new TestableUniformSession(pipelineContext);
            var behavior        = new SendingBehavior(uniformSession);

            await behavior.Invoke(pipelineContext, () => Task.CompletedTask);

            Assert.AreEqual(2, uniformSession.PublishedMessages.Length);
            Assert.AreEqual(2, uniformSession.SentMessages.Length);
            Assert.AreEqual(2, pipelineContext.PublishedMessages.Length);
            Assert.AreEqual(2, pipelineContext.SentMessages.Length);

            Assert.AreEqual("testValue", pipelineContext.Headers["testHeader"]);
        }
        public async Task Shares_state_with_handler_context()
        {
            var handlerContext = new TestableMessageHandlerContext();
            var uniformSession = new TestableUniformSession(handlerContext);
            var handler        = new SendingHandler(uniformSession);

            await handler.Handle(new SomeCommand(), handlerContext);

            Assert.AreEqual(2, uniformSession.PublishedMessages.Length);
            Assert.AreEqual(2, uniformSession.SentMessages.Length);
            Assert.AreEqual(2, handlerContext.PublishedMessages.Length);
            Assert.AreEqual(2, handlerContext.SentMessages.Length);

            Assert.IsTrue(handlerContext.DoNotContinueDispatchingCurrentMessageToHandlersWasCalled);
        }