public async Task WhenCalled_ThenTheConversationIsSavedToTheConversationRepository() { // arrange Conversation testConversation = null; OutgoingSms message = new OutgoingSmsBuilder(); _mockConversationRepository.Setup(m => m.Save(It.IsAny <Conversation>())) .Callback <Conversation>(c => { c.Id.Should().Be(message.Conversation.ConversationId); c.ActivityId.Should().Be(message.Conversation.ActivityId); c.TurnId.Should().Be(message.Conversation.TurnId); testConversation = c; }) .Returns(Task.CompletedTask); var command = new SendSmsCommand(message, _testQueueMessage); // act await _sut.HandleAsync(command); //assert _mockConversationRepository.Verify(m => m.Save(testConversation), Times.Once); }
public async Task WhenCalled_ThenTheSmsIsSentUsingToTheNotificationClient() { // arrange var mobileNumber = Guid.NewGuid().ToString(); var messageText = Guid.NewGuid().ToString(); var reference = Guid.NewGuid().ToString(); var message = new OutgoingSmsBuilder() .WithConversation(new BotConversationBuilder().WithConversationId(reference)) .WithMessageText(messageText) .WithParticipant(new ParticipantBuilder().WithUserId(mobileNumber)); var command = new SendSmsCommand(message, _testQueueMessage); // act await _sut.HandleAsync(command); //assert _mockNotificationClient.Verify(m => m.SendSms( mobileNumber, _testNotifyTemplateId, It.Is <Dictionary <string, dynamic> >(i => i.ContainsKey("message") && i.ContainsValue(messageText)), reference, _testNotifySmsSenderId) , Times.Once); }