public static Result Evaluate(this CreatePersonModel model) { var firstName = PersonFirstName.Create(model.FirstName); var name = PersonName.Create(model.Name); var email = PersonEmail.Create(model.Email); return Result.Combine(firstName, name, email); }
public static Person ToBusinessObject(this CreatePersonModel model) { return new Person( surrogateId: Option.None<string>(), firstName: PersonFirstName.Create(model.FirstName).Value, name: PersonName.Create(model.Name).Value, email: PersonEmail.Create(model.Email).Value); }
public static Person GetPersonWithoutId() { return(new Person( surrogateId: Option.None <string>(), firstName: PersonFirstName.Create("firstname").Value, name: PersonName.Create("name").Value, email: PersonEmail.Create("*****@*****.**").Value)); }
public static Person GetPerson(Option <PersonFirstName> firstName, Option <PersonName> name, Option <PersonEmail> email) { return(new Person( surrogateId: Option.None <string>(), firstName: firstName.ValueOr(PersonFirstName.Create("firstname").Value), name: name.ValueOr(PersonName.Create("name").Value), email: email.Else(Option.None <PersonEmail>()))); }
public static Person ToBusiness(this PersonEntity personEntity) { return(new Person( surrogateId: Option.Some(personEntity.Id), firstName: PersonFirstName.Create(personEntity.FirstName).Value, name: PersonName.Create(personEntity.Name).Value, email: PersonEmail.Create(personEntity.Email).Value)); }
private Person GetDefaultPerson() { return(new Person( Option.None <string>(), firstName: PersonFirstName.Create("firstname").Value, name: PersonName.Create("name").Value, email: PersonEmail.Create("*****@*****.**").Value )); }
public void FirstNameShouldBeTheSameAsConstructorParameter() { //Init var firstName = Option.Some(PersonFirstName.Create("firstname").Value); var name = Option.None <PersonName>(); var email = Option.None <PersonEmail>(); //Act var person = GetPerson(firstName, name, email); //Assert Check.That <string>(person.FirstName).IsEqualTo("firstname"); }
public void EmailCanBeEmpty() { //Init var firstName = Option.Some(PersonFirstName.Create("firstname").Value); var name = Option.Some(PersonName.Create("name").Value); var email = Option.None <PersonEmail>(); //Act var person = GetPerson(firstName, name, email); //Assert Check.That(person.Email.HasValue).IsFalse(); }
public void FirstNameShouldNotBeNull() { PersonFirstName firstName = null; Action action = () => { new Person( surrogateId: Option.None <string>(), firstName: firstName, name: PersonName.Create("name").Value, email: PersonEmail.Create("*****@*****.**").Value ); }; Check.ThatCode(action).Throws <ArgumentException>(); }
public ClientServiceImplTest() { this.person = new Person( Option.None <string>(), PersonFirstName.Create("john").Value, PersonName.Create("smith").Value, PersonEmail.Create("*****@*****.**").Value); this.personQuery = Substitute.For <PersonQuery>(); this.personQuery.Exist(this.person).Returns(true); var mediator = Substitute.For <IMediator>(); this.personRepository = Substitute.For <PersonRepository>(); this.accomodation = AccomodationTest.GetAccomodation(); this.accomodationQuery = Substitute.For <AccomodationQuery>(); this.accomodationQuery.Exist(this.accomodation).Returns(true); this.personQuery.IsAccomodationSold(this.accomodation).Returns(false); this.clientService = new ClientServiceImpl(this.personRepository, this.personQuery, this.accomodationQuery, mediator); }
public Person(Option <string> surrogateId, PersonFirstName firstName, PersonName name, Option <PersonEmail> email) : base(surrogateId) { this.FirstName = firstName; this.Name = name; this.Email = email; }