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); }
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); }