public void SMTPClient_ConfigurationInit_Tests() { // Arrange using var stream = new MemoryStream(Encoding.UTF8.GetBytes(@"{ ""SMTP"": { ""Host"": ""smtp.exmail.qq.com"", ""Port"": 465, ""UseSsl"": true, ""UserName"": ""*****@*****.**"", ""Password"": ""***"" } }")); var section = new ConfigurationBuilder().AddJsonStream(stream).Build().GetSection("SMTP"); var client = new SMTPClient(section); // Act var result = Assert.ThrowsAsync <AuthenticationException>(async() => { await client.SendAsync(message); }); // Assert Assert.IsTrue(result?.Message.StartsWith("535:")); }
public void EmailUtilSend_Test() { // Arrange var client = new SMTPClient(new SMTPClientSettings("smtp.exmail.qq.com", 465, true, "ETSOO <*****@*****.**>", "*****@*****.**", "***")); // Act var result = Assert.ThrowsAsync <AuthenticationException>(async() => { await client.SendAsync(message); }); // Assert Assert.IsTrue(result?.Message.StartsWith("535:")); }