I need to setup graphClient.Invitations.PostAsync() method. I need it to add some unit tests. But it looks like Invitations property cannot be mocked. Anywey, I am looking a way how to predefine a response.
My code is:
var options = new ClientSecretCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
};
var clientSecretCredential = new ClientSecretCredential(
this._configuration.TenantId,
this._configuration.ClientId,
this._configuration.ClientSecret,
options);
var graphClient = new GraphServiceClient(clientSecretCredential);
var invitation = new Invitation
{
InvitedUserEmailAddress = request.InvitedUserEmailAddress,
InviteRedirectUrl = request.InviteRedirectUrl,
InvitedUserType = SignInUserType.Member.ToString(),
SendInvitationMessage = true
};
try
{
var result = await graphClient.Invitations.PostAsync(invitation);
if (result == null)
{
// ...
}
}
catch (HttpRequestException ex)
{
// ...
}
How can I do this ?