示例#1
0
        public void NotProcessDuplicate()
        {
            var loggerMock         = new Mock <ILogger <BusinessEntitySaga> >();
            var businessEntitySaga = new BusinessEntitySaga(loggerMock.Object)
            {
                Data = new BusinessEntitySagaData
                {
                    StateDetails = new Dictionary <int, StateDetail>
                    {
                        { 123, new StateDetail() }
                    }
                }
            };
            var context = new TestableMessageHandlerContext();
            var message = new StateUpdated
            {
                BusinessEntityId = "qwerty",
                Details          = new StateDetail
                {
                    Id           = 123,
                    State        = "NEWSTATE",
                    TimeStampUtc = DateTime.UtcNow
                }
            };

            businessEntitySaga.Handle(message, context);

            // TODO verify business logic not executed twice
            Assert.Single(businessEntitySaga.Data.StateDetails);
        }
示例#2
0
        public void ProcessNewMessage()
        {
            var loggerMock         = new Mock <ILogger <BusinessEntitySaga> >();
            var businessEntitySaga = new BusinessEntitySaga(loggerMock.Object)
            {
                Data = new BusinessEntitySagaData()
            };
            var context = new TestableMessageHandlerContext();
            var message = new StateUpdated
            {
                BusinessEntityId = "qwerty",
                Details          = new StateDetail
                {
                    Id           = 123,
                    State        = "NEWSTATE",
                    TimeStampUtc = DateTime.UtcNow
                }
            };

            businessEntitySaga.Handle(message, context);

            // TODO verify business logic is executed
            Assert.Single(businessEntitySaga.Data.StateDetails);
        }