public void ShouldRemoveSagaIfCompleted()
            {
                var consumingContextMock = new Mock <IConsumingContext <IncomingEvent> >();

                consumingContextMock.SetupGet(cc => cc.Message)
                .Returns(new Message <IncomingEvent>(string.Empty.ToMessageLabel(), new IncomingEvent()));

                var sagaMock = new Mock <ISagaContext <Data, string> >();

                sagaMock.SetupGet(s => s.Completed).Returns(true);

                var sagaRepositoryMock = new Mock <ISagaRepository <Data, string> >();

                sagaRepositoryMock.Setup(sr => sr.Get(It.IsAny <string>()))
                .Returns(sagaMock.Object);

                var sagaFactoryMock = new Mock <ISagaFactory <Data, string> >();

                sagaFactoryMock.Setup(sf => sf.Create(It.IsAny <string>()))
                .Returns(sagaMock.Object);

                var sagaIdSeparatorMock = new Mock <ISagaIdSeparator <IncomingEvent, string> >();

                var sut = new DefaultSagaLifecycle <Data, IncomingEvent, string>(sagaRepositoryMock.Object, sagaIdSeparatorMock.Object, sagaFactoryMock.Object);

                sut.FinilizeSaga(sagaMock.Object);

                sagaRepositoryMock.Verify(sr => sr.Remove(It.IsAny <ISagaContext <Data, string> >()), "Сага должна быть удалена после завершения.");
            }
            public void ShouldStoreSagaAfterHandle()
            {
                var consumingContextMock = new Mock <IConsumingContext <IncomingEvent> >();

                consumingContextMock.SetupGet(cc => cc.Message)
                .Returns(new Message <IncomingEvent>(string.Empty.ToMessageLabel(), new IncomingEvent()));

                var sagaMock = new Mock <ISagaContext <Data, string> >();

                var sagaRepositoryMock = new Mock <ISagaRepository <Data, string> >();

                sagaRepositoryMock.Setup(sr => sr.Get(It.IsAny <string>()))
                .Returns(sagaMock.Object);

                var sagaFactoryMock = new Mock <ISagaFactory <Data, string> >();

                var sagaIdSeparatorMock = new Mock <ISagaIdSeparator <IncomingEvent, string> >();

                var sut = new DefaultSagaLifecycle <Data, IncomingEvent, string>(sagaRepositoryMock.Object, sagaIdSeparatorMock.Object, sagaFactoryMock.Object);

                sut.FinilizeSaga(sagaMock.Object);

                sagaRepositoryMock.Verify(sr => sr.Store(It.IsAny <ISagaContext <Data, string> >()), "Сага должна сохраняться после обработки.");
            }
            public void ShouldStoreSagaAfterHandle()
            {
                var consumingContextMock = new Mock<IConsumingContext<IncomingEvent>>();
                consumingContextMock.SetupGet(cc => cc.Message)
                    .Returns(new Message<IncomingEvent>(string.Empty.ToMessageLabel(), new IncomingEvent()));

                var sagaMock = new Mock<ISagaContext<Data, string>>();

                var sagaRepositoryMock = new Mock<ISagaRepository<Data, string>>();
                sagaRepositoryMock.Setup(sr => sr.Get(It.IsAny<string>()))
                    .Returns(sagaMock.Object);

                var sagaFactoryMock = new Mock<ISagaFactory<Data, string>>();

                var sagaIdSeparatorMock = new Mock<ISagaIdSeparator<IncomingEvent, string>>();

                var sut = new DefaultSagaLifecycle<Data, IncomingEvent, string>(sagaRepositoryMock.Object, sagaIdSeparatorMock.Object, sagaFactoryMock.Object);

                sut.FinilizeSaga(sagaMock.Object);

                sagaRepositoryMock.Verify(sr => sr.Store(It.IsAny<ISagaContext<Data, string>>()), "Сага должна сохраняться после обработки.");
            }
            public void ShouldRemoveSagaIfCompleted()
            {
                var consumingContextMock = new Mock<IConsumingContext<IncomingEvent>>();
                consumingContextMock.SetupGet(cc => cc.Message)
                    .Returns(new Message<IncomingEvent>(string.Empty.ToMessageLabel(), new IncomingEvent()));

                var sagaMock = new Mock<ISagaContext<Data, string>>();
                sagaMock.SetupGet(s => s.Completed).Returns(true);

                var sagaRepositoryMock = new Mock<ISagaRepository<Data, string>>();
                sagaRepositoryMock.Setup(sr => sr.Get(It.IsAny<string>()))
                    .Returns(sagaMock.Object);

                var sagaFactoryMock = new Mock<ISagaFactory<Data, string>>();
                sagaFactoryMock.Setup(sf => sf.Create(It.IsAny<string>()))
                    .Returns(sagaMock.Object);

                var sagaIdSeparatorMock = new Mock<ISagaIdSeparator<IncomingEvent, string>>();

                var sut = new DefaultSagaLifecycle<Data, IncomingEvent, string>(sagaRepositoryMock.Object, sagaIdSeparatorMock.Object, sagaFactoryMock.Object);

                sut.FinilizeSaga(sagaMock.Object);

                sagaRepositoryMock.Verify(sr => sr.Remove(It.IsAny<ISagaContext<Data, string>>()), "Сага должна быть удалена после завершения.");
            }