Last active
June 20, 2023 19:25
-
-
Save maiconheck/c3e5b6fe90c5fefd250aee64807a588a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Trait("Category", "Domain")] | |
public class EmailTest | |
{ | |
[Fact] | |
public void ToString_Email_String() | |
{ | |
var expected = "foo@domain.com"; | |
var email = new Email(expected); | |
var actual = email.ToString(); | |
Assert.Equal(expected, actual); | |
} | |
[Fact] | |
public void ToEmail_String_Email() | |
{ | |
var expected = "foo@domain.com"; | |
var actual = Email.ToEmail(expected); | |
Assert.Equal(expected, actual.EmailAddress); | |
} | |
[Theory] | |
[InlineData("foo@domain.com")] | |
[InlineData("foo.foo@domain.com")] | |
[InlineData("a@b.c")] | |
public void Email_ValidEmailAddress_Valid(string emailAddress) | |
{ | |
Assert.DoesNotThrows(() => new Email(emailAddress)); | |
} | |
[Theory] | |
[InlineData("foo@.com")] | |
[InlineData("@.com")] | |
[InlineData("foo@com")] | |
[InlineData("@domain.com")] | |
[InlineData("foo@domain,com")] | |
public void Email_InvalidEmailAddress_Invalid(string emailAddress) | |
{ | |
Assert.Throws<FormatException>(() => new Email(emailAddress)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment