public async Task Should_handle_timeout_properly()
        {
            var sut = new SmtpEmailSender(Options.Create(new SmtpOptions
            {
                Sender  = "*****@*****.**",
                Server  = "invalid",
                Timeout = 1000
            }));

            var timer = Task.Delay(5000);

            var result = await Task.WhenAny(timer, sut.SendAsync("*****@*****.**", "TEST", "TEST"));

            Assert.NotSame(timer, result);
        }
Esempio n. 2
0
        public async Task Should_handle_timeout_properly()
        {
            var options = TestConfig.Configuration.GetSection("email:smtp").Get <SmtpOptions>();

            var recipient = TestConfig.Configuration["email:smtp:recipient"];

            var testSubject = TestConfig.Configuration["email:smtp:testSubject"];
            var testBody    = TestConfig.Configuration["email:smtp:testBody"];

            var sut = new SmtpEmailSender(Options.Create(options));

            using (var cts = new CancellationTokenSource(5000))
            {
                await sut.SendAsync(recipient, testSubject, testBody, cts.Token);
            }
        }