public async Task ThenProcessandStoreMessage() { //Arrange await base.SetupDatabase(); var message = new RejectedTransferConnectionInvitationEvent() { CreatedAt = DateTime.UtcNow, SenderAccountHashedId = "aabbcc16", SenderAccountId = 12345, RejectorUserId = 98765, ReceiverAccountId = 54321 }; var logger = new TraceWriterStub(TraceLevel.Verbose); var sentMessage = new WhenAStartTransferRequestEventIsRecieved(); await sentMessage.ThenProcessandStoreMessage(); //Act DAS.Data.Functions.Transfers.ProcessTransferRelationshipRejectedMessage.Run(message, null, logger, transferRelationshipService, log); //Assert // Assert.AreEqual(1, logger.Traces.Count); var databaseAsExpected = TestHelper.ConditionMet(IsDatabaseInExpectedState, TimeSpan.FromSeconds(60)); Assert.IsTrue(databaseAsExpected); }
public static void RunDLQ([ServiceBusTrigger("rejected_transfer_connection_invitation", "RDS_RejectedTransferConnectionInvitiationProcessor/$DeadLetterQueue", AccessRights.Manage, Connection = "MessageBusConnectionString")] BrokeredMessage bMessage, ExecutionContext executionContext, TraceWriter log, [Inject] ITransferRelationshipService transferRelationshipMessageService, [Inject] ILog logger) { log.Info($"Processing messageId: {bMessage.MessageId} {{ID={executionContext.InvocationId}}}"); RejectedTransferConnectionInvitationEvent messageBody = null; try { messageBody = bMessage.GetBody <RejectedTransferConnectionInvitationEvent>(); } catch (Exception e) { log.Error($"Unable to deserialize message body for message queue sent_transfer_connection_invitation. messageId: {bMessage.MessageId} {{ID={executionContext.InvocationId}}}", e); bMessage.Defer(); } if (messageBody != null) { try { transferRelationshipMessageService.SaveRejectedMessage(messageBody); log.Info($"Processing Completed for messageId: {bMessage.MessageId} {{ID={executionContext.InvocationId}}}"); bMessage.Complete(); } catch (Exception e) { log.Error($"Unable to save message for queue sent_transfer_connection_invitation DLQ. messageId: {bMessage.MessageId} {{ID={executionContext.InvocationId}}}", e); bMessage.Defer(); } } }
public void AndIsATransferRejectedMessageThenSaveMessageDetails() { var rejectedMessage = new RejectedTransferConnectionInvitationEvent(); _transferRelationshipRepositoryMock.Setup(s => s.SaveTransferRelationship(It.IsAny <TransferRelationship>())).Returns(Task.FromResult(true)); _service.SaveRejectedMessage(rejectedMessage); _transferRelationshipRepositoryMock.Verify(v => v.SaveTransferRelationship(It.IsAny <TransferRelationship>())); }
public void SaveRejectedMessage(RejectedTransferConnectionInvitationEvent message) { var senderUserId = GetSenderUserId(message.SenderAccountId, message.ReceiverAccountId); var transferRelationship = new TransferRelationship() { SenderAccountId = message.SenderAccountId, ReceiverAccountId = message.ReceiverAccountId, SenderUserId = senderUserId, RelationshipStatus = TransferRelationshipStatus.Rejected, RejectorUserId = message.RejectorUserId }; _transferRelationshipRepository.SaveTransferRelationship(transferRelationship); }
public void Arrange() { _subscriptionFactory = new Mock <IMessageSubscriberFactory>(); _subscriber = new Mock <IMessageSubscriber <RejectedTransferConnectionInvitationEvent> >(); _messageContent = new RejectedTransferConnectionInvitationEvent(); _mockMessage = new Mock <IMessage <RejectedTransferConnectionInvitationEvent> >(); _mockMessage.Setup(x => x.Content).Returns(_messageContent); _mediator = new Mock <IMediator>(); _tokenSource = new CancellationTokenSource(); _processor = new Worker.MessageProcessors.RejectedTransferConnectionInvitationMessageProcessor(_subscriptionFactory.Object, Mock.Of <ILog>(), _mediator.Object); _subscriptionFactory.Setup(x => x.GetSubscriber <RejectedTransferConnectionInvitationEvent>()).Returns(_subscriber.Object); _subscriber.Setup(x => x.ReceiveAsAsync()) .ReturnsAsync(() => _mockMessage.Object) .Callback(() => _tokenSource.Cancel()); }
public static void Run([ServiceBusTrigger("rejected_transfer_connection_invitation", "RDS_RejectedTransferConnectionInvitiationProcessor", AccessRights.Manage, Connection = "MessageBusConnectionString")] RejectedTransferConnectionInvitationEvent message, ExecutionContext executionContext, TraceWriter log, [Inject] ITransferRelationshipService transferRelationshipMessageService, [Inject] ILog logger) { transferRelationshipMessageService.SaveRejectedMessage(message); logger.Info($"C# service bus trigger function executed at ProcessTransferRelationshipStartMessage: {DateTime.Now}"); }