Fix EmailNotificationTransportServiceTests

This commit is contained in:
ngfrolov 2024-01-10 17:57:58 +05:00
parent 67481a7743
commit c2f69463d2
Signed by untrusted user who does not match committer: ng.frolov
GPG Key ID: E99907A0357B29A7
2 changed files with 3 additions and 11 deletions

View File

@ -2,9 +2,7 @@
using AsbCloudApp.Exceptions;
using AsbCloudApp.Repositories;
using AsbCloudApp.Services.Notifications;
using AsbCloudInfrastructure.Background;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

View File

@ -62,17 +62,11 @@ namespace AsbCloudWebApi.Tests.UnitTests.Services.Notification
}
[Fact]
public async Task SendAsync()
public async Task SendAsyncThrowsMailboxUnavailable()
{
userRepository.GetOrDefaultAsync(Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns(user);
try
{
await notificationTransportService.SendAsync(notification, CancellationToken.None);
}
catch (Exception e)
{
Assert.True(e is SmtpException);
}
var exception = await Assert.ThrowsAsync<SmtpException>(() => notificationTransportService.SendAsync(notification, CancellationToken.None));
Assert.Equal(SmtpStatusCode.MailboxUnavailable, exception.StatusCode);
}
}
}