public async Task WhenAddressIsNullOrEmpty_ShouldThrow() { using (var client = new HttpGuardpostClient(MailgunPublicApiKey)) { await client.ValidateAsync(null).ConfigureAwait(false); } }
public async Task WhenAddressIsGreaterThan512Characters_ShouldThrow() { using (var client = new HttpGuardpostClient(MailgunPublicApiKey)) { var address = new string('a', 513); await client.ValidateAsync(address).ConfigureAwait(false); } }
public async Task WhenAddressIsValid_ShouldReturn() { using (var client = new HttpGuardpostClient(MailgunPublicApiKey)) { //[email protected]: Meets Gmail 6 character minimum and all other requirements. var address = "*****@*****.**"; var validateResponse = await client.ValidateAsync(address).ConfigureAwait(false); Assert.IsNotNull(validateResponse); Assert.IsTrue(validateResponse.IsValid); Assert.AreEqual(address, validateResponse.Address); Assert.IsNotNull(validateResponse.Parts); Assert.AreEqual("gmail.com", validateResponse.Parts.Domain); Assert.AreEqual("johnsmith", validateResponse.Parts.LocalPart); Assert.IsNull(validateResponse.DidYouMean); } }
public async Task WhenAddressIsInvalid_ShouldReturn() { using (var client = new HttpGuardpostClient(MailgunPublicApiKey)) { //[email protected]: Does not meet Gmail minimum local-part length of 6 characters. var address = "*****@*****.**"; var validateResponse = await client.ValidateAsync(address).ConfigureAwait(false); Assert.IsNotNull(validateResponse); Assert.IsFalse(validateResponse.IsValid); Assert.AreEqual(address, validateResponse.Address); Assert.IsNotNull(validateResponse.Parts); Assert.IsNull(validateResponse.Parts.Domain); Assert.IsNull(validateResponse.Parts.LocalPart); Assert.IsNull(validateResponse.DidYouMean); } }
public async Task WhenApiKeyIsInvalid_ShouldThrow() { using (var client = new HttpGuardpostClient("invalidApiKey")) { await client.ValidateAsync("*****@*****.**").ConfigureAwait(false); } }
public async Task WhenSyntaxOnlyIsFalse() { using (var client = new HttpGuardpostClient(MailgunPublicApiKey)) { var parseResponse = await client.ParseAsync(new[] { "*****@*****.**", "*****@*****.**", "gmail.com" }, false).ConfigureAwait(false); Assert.IsNotNull(parseResponse); Assert.IsNotNull(parseResponse.Parsed); Assert.IsNotNull(parseResponse.Unparseable); Assert.AreEqual(1, parseResponse.Parsed.Length); Assert.IsTrue(parseResponse.Parsed.Contains("*****@*****.**")); Assert.AreEqual(2, parseResponse.Unparseable.Length); Assert.IsTrue(parseResponse.Unparseable.Contains("*****@*****.**")); Assert.IsTrue(parseResponse.Unparseable.Contains("gmail.com")); } }
public async Task WhenAddressesIsEmpty_ShouldReturn() { using (var client = new HttpGuardpostClient(MailgunPublicApiKey)) { var parseResponse = await client.ParseAsync(Enumerable.Empty<string>(), true).ConfigureAwait(false); Assert.IsNotNull(parseResponse); Assert.IsNotNull(parseResponse.Parsed); Assert.IsNotNull(parseResponse.Unparseable); Assert.IsFalse(parseResponse.Parsed.Any()); Assert.IsFalse(parseResponse.Unparseable.Any()); } }
public async Task WhenAddressesIsNull_ShouldThrow() { using (var client = new HttpGuardpostClient(MailgunPublicApiKey)) { await client.ParseAsync(null, true).ConfigureAwait(false); } }