public void can_add_new_person_with_phone_number() { GenerateDatabaseSchema(); Person p = new Person() { Id = 1, Forename = "Jimmy", Surname = "Choo", BirthdayDay = 1, BirthdayMonth = 1 }; PhoneNumber num = new PhoneNumber(1, "12345678"); p.AddPhoneNumber(num); IPersonRepository repository = new PersonRepository(); repository.Add(p); using (ISession session = _sessionFactory.OpenSession()) { Person databasePerson; databasePerson = session.Get<Person>(p.Id); Assert.IsNotNull(databasePerson, "Person not loaded from Database"); Assertions.AssertPeopleAreEqual(p, databasePerson); Assert.AreEqual(1, databasePerson.PhoneNumbers.Count, "List does not contain one phone number"); foreach (PhoneNumber number in databasePerson.PhoneNumbers) { Assert.AreEqual(num.Id, number.Id, "Id of phone number not equal"); Assert.AreEqual(num.Number, number.Number, "Id of phone number not equal"); } } }
public void can_add_new_person() { GenerateDatabaseSchema(); Person p = new Person() { Id = 1, Forename = "Jimmy", Surname = "Choo", BirthdayDay = 1, BirthdayMonth = 1 }; IPersonRepository repository = new PersonRepository(); repository.Add(p); using (ISession session = _sessionFactory.OpenSession()) { Person databasePerson; databasePerson = session.Get<Person>(p.Id); Assert.IsNotNull(databasePerson, "Person not loaded from Database"); Assertions.AssertPeopleAreEqual(p, databasePerson); } }
public void can_add_new_person_with_email() { GenerateDatabaseSchema(); Person p = new Person() { Id = 1, Forename = "Jimmy", Surname = "Choo", BirthdayDay = 1, BirthdayMonth = 1 }; p.AddEmail("*****@*****.**"); IPersonRepository repository = new PersonRepository(); repository.Add(p); using (ISession session = _sessionFactory.OpenSession()) { Person databasePerson; databasePerson = session.Get<Person>(p.Id); Assert.IsNotNull(databasePerson, "Person not loaded from Database"); Assertions.AssertPeopleAreEqual(p, databasePerson); Assert.IsTrue(databasePerson.EmailAddresses.Contains("*****@*****.**"), "Email address not found"); } }