public void Save_Returns_SavedData()
        {
            //Arrange
            var correlationId = Guid.NewGuid();
            var saga          = new MySaga {
                CorrelationId = correlationId
            };

            // Act
            sut.Save(saga);

            // Assert
            sut.DataDictionary.Should().NotBeNull()
            .And.HaveCount(1)
            .And.ContainKey(correlationId);
        }
Exemplo n.º 2
0
        public void Consumed_PipelineHooks_ExecutedInOrder()
        {
            //Arrange
            var correlationId = Guid.NewGuid();

            repository.Save(new MySaga()
            {
                CorrelationId = correlationId
            });

            var message = new MySagaConsumingMessage(correlationId);

            // Act
            sut.Consume(message);

            // Assert
            Received.InOrder(() =>
            {
                pipelineHook.BeforeConsuming(Arg.Any <PipelineContext>());
                pipelineHook.AfterConsuming(Arg.Any <PipelineContext>());
                pipelineHook.AfterSave(Arg.Any <PipelineContext>());
            });
        }
Exemplo n.º 3
0
        public void Initiate_SagaAlreadyExists_Throws()
        {
            // Arrange
            var correlationId = Guid.NewGuid();

            repository.Save(new MySaga()
            {
                CorrelationId = correlationId
            });
            var initiatingMessage = new MySagaInitiatingMessage(correlationId);

            // Act
            Action act = () => sut.Consume(initiatingMessage);

            // Assert
            act.ShouldThrow <ArgumentException>().Which.Message.Contains("Trying to initiate the same saga twice");
        }