コード例 #1
0
        public void Initiate_NoCorrelationId_Throws()
        {
            // Arrange
            var initiatingMessage = new MySagaInitiatingMessage();

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

            // Assert
            act.ShouldThrow <ArgumentException>().Which.Message.Contains("CorrelationId was not provided in the message");
        }
コード例 #2
0
        public void GetSagaTypesInitiatedBy_Returns_MySaga()
        {
            // Arrange
            var initiatingMessage = new MySagaInitiatingMessage();

            // Act
            var result = NSagaReflection.GetSagaTypesInitiatedBy(initiatingMessage, typeof(NSagaReflectionTests).Assembly);

            // Assert
            result.Should().HaveCount(1).And.Contain(typeof(MySaga));
        }
コード例 #3
0
        public void Initiate_CalledInitiate_CheckData()
        {
            //Arrange
            var correlationId     = Guid.NewGuid();
            var initiatingMessage = new MySagaInitiatingMessage(correlationId);

            // Act
            sut.Consume(initiatingMessage);

            // Assert
            var saga = repository.Find <MySaga>(correlationId);

            saga.SagaData.IsInitialised.Should().BeTrue();
        }
コード例 #4
0
        public void Initiate_Saves_IntoRepository()
        {
            //Arrange
            var correlationId     = Guid.NewGuid();
            var initiatingMessage = new MySagaInitiatingMessage(correlationId);

            // Act
            sut.Consume(initiatingMessage);

            // Assert
            repository.DataDictionary.Should().HaveCount(1);
            var saga = repository.Find <MySaga>(correlationId);

            saga.CorrelationId.Should().Be(correlationId);
        }
コード例 #5
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");
        }
コード例 #6
0
ファイル: MySaga.cs プロジェクト: shanselman/NSaga
        public OperationResult Initiate(MySagaInitiatingMessage message)
        {
            SagaData.IsInitialised = true;

            return(new OperationResult());
        }