Skip to content

Commit

Permalink
ShouldSendAndSaveCopyIfOnlyToAddressAddedAsync -> FAIL
Browse files Browse the repository at this point in the history
  • Loading branch information
mabroukmahdhi committed Aug 11, 2024
1 parent f04a093 commit bd9eb09
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions FlexiMail.Tests.Unit/Services/FlexiExchangeServiceTests.Logics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,46 @@ public async void ShouldSendAndSaveCopyAsync()
broker.SendAndSaveCopy(It.IsAny<EmailMessage>()),
Times.Once);
}

[Fact]
public async void ShouldSendAndSaveCopyIfOnlyToAddressAddedAsync()
{
// given
var randomAccessToken = GetRandomString();
var randomMessage = CreateRandomFlexiMessage();
randomMessage.Bcc = null;
randomMessage.Cc = null;
var randomExchangeService = CreateExchangeService();

this.exchangeBrokerMock.Setup(broker =>
broker.GetAccessTokenAsync())
.ReturnsAsync(randomAccessToken);

this.exchangeBrokerMock.Setup(broker =>
broker.CreateExchangeService(
ExchangeVersion.Exchange2013,
randomAccessToken,
It.IsAny<ImpersonatedUserId>()))
.Returns(randomExchangeService);

// when
await this.flexiExchangeService.SendAndSaveCopyAsync(randomMessage);

// then
this.exchangeBrokerMock.Verify(broker =>
broker.GetAccessTokenAsync(),
Times.Once);

this.exchangeBrokerMock.Verify(broker =>
broker.CreateExchangeService(
ExchangeVersion.Exchange2013,
randomAccessToken,
It.IsAny<ImpersonatedUserId>()),
Times.Once);

this.exchangeBrokerMock.Verify(broker =>
broker.SendAndSaveCopy(It.IsAny<EmailMessage>()),
Times.Once);
}
}
}

0 comments on commit bd9eb09

Please sign in to comment.