Exemplo n.º 1
0
        public void GetMessageId__MessageTypeIsNotRegistered__IdIsNull()
        {
            var objectWithMessageId = new MessageWithSomeId()
            {
                MessageId = Guid.NewGuid().ToString()
            };
            var messageCancellationRegistry = new MessageCancellationRegistry();
            var messageId = messageCancellationRegistry.GetMessageIdOrDefault(objectWithMessageId);

            Assert.Null(messageId);
        }
Exemplo n.º 2
0
        public void GetMessageId__MessageTypeIsRegistered__IdReceived()
        {
            var objectWithMessageId = new MessageWithSomeId()
            {
                MessageId = Guid.NewGuid().ToString()
            };
            var messageCancellationRegistry = new MessageCancellationRegistry();

            //Example of a message registration
            messageCancellationRegistry.RegisterTypeWithMessageId <MessageWithSomeId>((x) => x.MessageId);
            var messageId = messageCancellationRegistry.GetMessageIdOrDefault(objectWithMessageId);

            Assert.Equal(objectWithMessageId.MessageId, messageId);
        }
Exemplo n.º 3
0
        private static MessageWithSomeId PrepareServicesForInterception(out string operationId,
                                                                        out MessageCancellationService messageCancellationService,
                                                                        out MessageCancellationRegistry messageCancellationRegistry, out Mock <ILogFactory> logFactory)
        {
            operationId = Guid.NewGuid().ToString();
            var message = new MessageWithSomeId()
            {
                MessageId = operationId
            };

            messageCancellationService  = new MessageCancellationService();
            messageCancellationRegistry = new MessageCancellationRegistry();
            messageCancellationRegistry.RegisterTypeWithMessageId <MessageWithSomeId>(x => x.MessageId.ToString());
            messageCancellationService.RequestMessageCancellationAsync(operationId).Wait();
            logFactory = new Mock <ILogFactory>();
            logFactory.Setup(x => x.CreateLog(It.IsAny <object>())).Returns(new Mock <ILog>().Object);

            return(message);
        }