yavsc/test/Mandatory/EMailling.cs

45 lines
1.5 KiB
C#

using Microsoft.Extensions.Logging;
using Xunit;
using Xunit.Abstractions;
using Yavsc.Abstract.Manage;
6 years ago
namespace test
{
[Collection("EMaillingTeststCollection")]
6 years ago
[Trait("regres", "no")]
public class EMaillingTests : IClassFixture<ServerSideFixture>
{
ServerSideFixture _serverFixture;
ITestOutputHelper output;
6 years ago
ILogger _logger;
public EMaillingTests(ServerSideFixture serverFixture, ITestOutputHelper output)
{
this.output = output;
_serverFixture = serverFixture;
6 years ago
_logger = serverFixture.Logger;
}
[Fact]
public void SendEMailSynchrone()
{
AssertAsync.CompletesIn(2, () =>
{
output.WriteLine("SendEMailSynchrone ...");
6 years ago
EmailSentViewModel mailSentInfo = _serverFixture.MailSender.SendEmailAsync
(_serverFixture.SiteSetup.Owner.Name, _serverFixture.SiteSetup.Owner.EMail, $"monthly email", "test boby monthly email").Result;
if (mailSentInfo==null)
6 years ago
_logger.LogError("No info on sending");
else if (!mailSentInfo.Sent)
6 years ago
_logger.LogError($"{mailSentInfo.ErrorMessage}");
else
6 years ago
_logger.LogInformation($"mailId:{mailSentInfo.MessageId} \nto:{_serverFixture.SiteSetup.Owner.Name}");
Assert.NotNull(mailSentInfo);
output.WriteLine($">>done with {mailSentInfo.EMail} {mailSentInfo.Sent} {mailSentInfo.MessageId} {mailSentInfo.ErrorMessage}");
});
}
}
6 years ago
}