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
public class Email | |
{ | |
public Email(string emailAddress) | |
{ | |
Guard.Against.InvalidEmail(emailAddress); | |
EmailAddress = emailAddress; | |
} | |
public string EmailAddress { get; } |
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", nameof(Domain))] | |
public class AddressTest | |
{ | |
[Theory] | |
[InlineData("79074-047")] | |
[InlineData("29725-972")] | |
public void Address_ValidZipCode_Valid(string zipCode) | |
{ | |
Assert.DoesNotThrows(() => new Address(zipCode, "Rua Júlio de Castilhos", 1234, "Centro")); | |
} |
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(); |
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", nameof(Domain))] | |
public class NameTest | |
{ | |
[Theory] | |
[InlineData("Lucas Luís", "Cruz")] | |
[InlineData("Erick Oliveira", "")] | |
public void Name_ValidName_Valid(string firstName, string lastName) | |
{ | |
Assert.DoesNotThrows(() => new Name(firstName, lastName)); | |
} |
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
var phoneNumber = new PhoneNumber("51", "25615006"); | |
var address = new Address("79074-047", "Rua Júlio de Castilhos", 1234, "Centro"); | |
var name = new Name("Lucas Luís", "Cruz"); | |
var email = new Email("foo@domain.com"); | |
var lead = new Lead(name, email); | |
lead.CompleteInfo(phoneNumber, address, false, new DateTime(2000, 12, 20)); |
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
public class Lead : Entity | |
{ | |
private readonly List<Segment> _segments = new List<Segment>(); | |
public Name Name { get; } | |
public Email Email { get; } | |
public IReadOnlyCollection<Segment> Segments => _segments.ToList(); | |
} |
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
public class Lead : Entity | |
{ | |
private readonly List<Segment> _segments; | |
public Lead(Name name, Email email) | |
{ | |
Guard.Against | |
.Null(name, nameof(name)) | |
.Null(email, nameof(email)); |
OlderNewer