Exemplo n.º 1
0
        public async Task ShouldEnqueueMessageForProcessing()
        {
            var testableSaga = new TestableSaga <MySaga, MyData>();

            var startResult = await testableSaga.Handle(new StartMsg { CorrId = "abc" });

            Assert.That(startResult.Context.SentMessages.Count, Is.EqualTo(1));
            Assert.That(testableSaga.QueueLength, Is.EqualTo(1));
            Assert.That(testableSaga.QueuePeek().Type, Is.EqualTo(typeof(SendToSelfCmd)));

            var continueResult = await testableSaga.HandleQueuedMessage();

            var doneEvt = continueResult.FindPublishedMessage <DoneEvent>();

            Assert.That(doneEvt.CorrId, Is.EqualTo("abc"));
        }
Exemplo n.º 2
0
        public async Task ExternalHandlerShouldSupplyReplyMessage()
        {
            var testableSaga = new TestableSaga <MySaga, MyData>();

            testableSaga.SimulateReply <RunStep1Command, Step1Response>(cmd => new Step1Response());

            var startResult = await testableSaga.Handle(new StartMsg { CorrId = "abc" });

            Assert.That(startResult.Context.SentMessages.Count, Is.EqualTo(1));
            Assert.That(testableSaga.QueueLength, Is.EqualTo(1));
            Assert.That(testableSaga.QueuePeek().Type, Is.EqualTo(typeof(Step1Response)));

            var continueResult = await testableSaga.HandleQueuedMessage();

            var doneEvt = continueResult.FindPublishedMessage <DoneEvent>();

            Assert.That(doneEvt.CorrId, Is.EqualTo("abc"));
        }