public void GetAnExistingContactReturnEntity() { var entity = ContactEntityObjectMother.Random(); entity.AddEmailAddress(EmailValueObjectObjectMother.Random()); entity.AddEmailAddress(EmailValueObjectObjectMother.Random()); entity.AddEmailAddress(EmailValueObjectObjectMother.Random()); entity.AddPhoneNumber(PhoneValueObjectObjectMother.Random()); entity.AddPhoneNumber(PhoneValueObjectObjectMother.Random()); _repo.Add(entity); _context.SaveChanges(); var fromRepo = _repo.GetById(entity.Id); Assert.IsNotNull(fromRepo); Assert.AreEqual(entity.Id, fromRepo.Id); Assert.AreEqual(entity.Name, fromRepo.Name); Assert.AreEqual(entity.EmailAddresses.Count, fromRepo.EmailAddresses.Count); Assert.AreEqual(entity.PhoneNumbers.Count, fromRepo.PhoneNumbers.Count); foreach (var email in entity.EmailAddresses) { Assert.IsTrue(fromRepo.EmailAddresses.Contains(email)); } foreach (var phone in entity.PhoneNumbers) { Assert.IsTrue(fromRepo.PhoneNumbers.Contains(phone)); } }
public void ObjectsWithSameValuesAreEquals() { var random = PhoneValueObjectObjectMother.Random(); var vo1 = new PhoneValueObject(random.PhoneType, random.PhoneNumber); var vo2 = new PhoneValueObject(random.PhoneType, random.PhoneNumber); Assert.NotNull(vo1); Assert.NotNull(vo2); Assert.AreEqual(vo1, vo2); }
public void ContactAddPhoneNumbersAddNonExistingOrNull() { var contact = ContactEntityObjectMother.Random(); var phone1 = PhoneValueObjectObjectMother.Random(); contact.AddPhoneNumber(phone1); contact.AddEmailAddress(null); contact.AddPhoneNumber(phone1); Assert.AreEqual(1, contact.PhoneNumbers.Count); Assert.IsTrue(contact.PhoneNumbers.Contains(phone1)); }
public void ContactAddPhoneNumbersAddsPhoneNumbers() { var contact = ContactEntityObjectMother.Random(); var phone1 = PhoneValueObjectObjectMother.Random(); var phone2 = PhoneValueObjectObjectMother.Random(); contact.AddPhoneNumber(phone1); contact.AddPhoneNumber(phone2); Assert.AreEqual(2, contact.PhoneNumbers.Count); Assert.IsTrue(contact.PhoneNumbers.Contains(phone1)); Assert.IsTrue(contact.PhoneNumbers.Contains(phone2)); }
public void ContactRemoveAllPhoneNumbersRemoveAllPhoneNumbers() { var contact = ContactEntityObjectMother.Random(); var phone1 = PhoneValueObjectObjectMother.Random(); var phone2 = PhoneValueObjectObjectMother.Random(); contact.AddPhoneNumber(phone1); contact.AddPhoneNumber(phone2); contact.RemoveAllPhoneNumbers(); Assert.AreEqual(0, contact.PhoneNumbers.Count); }
public void ContactRemovePhoneNumberDoesNotThrowError() { var contact = ContactEntityObjectMother.Random(); var phone1 = PhoneValueObjectObjectMother.Random(); var phone2 = PhoneValueObjectObjectMother.Random(); contact.AddPhoneNumber(phone1); contact.RemovePhoneNumber(phone2); Assert.AreEqual(1, contact.PhoneNumbers.Count); Assert.IsTrue(contact.PhoneNumbers.Contains(phone1)); }
public void AddContactAddTheEntity() { var entity = ContactEntityObjectMother.Random(); entity.AddEmailAddress(EmailValueObjectObjectMother.Random()); entity.AddEmailAddress(EmailValueObjectObjectMother.Random()); entity.AddEmailAddress(EmailValueObjectObjectMother.Random()); entity.AddPhoneNumber(PhoneValueObjectObjectMother.Random()); entity.AddPhoneNumber(PhoneValueObjectObjectMother.Random()); _repo.Add(entity); _context.SaveChanges(); VerifySaved(entity); }
public void DeleteRemoveTheContact() { var entity = ContactEntityObjectMother.Random(); entity.AddEmailAddress(EmailValueObjectObjectMother.Random()); entity.AddEmailAddress(EmailValueObjectObjectMother.Random()); entity.AddEmailAddress(EmailValueObjectObjectMother.Random()); entity.AddPhoneNumber(PhoneValueObjectObjectMother.Random()); entity.AddPhoneNumber(PhoneValueObjectObjectMother.Random()); _repo.Add(entity); _context.SaveChanges(); _repo.Delete(entity.Id); _context.SaveChanges(); Assert.IsFalse(_context.Contacts.Any(x => x.Id == entity.Id.Value)); Assert.IsFalse(_context.ContactEmails.Any(x => x.ContactId == entity.Id.Value)); Assert.IsFalse(_context.ContactPhones.Any(x => x.ContactId == entity.Id.Value)); }
public void ContactAddPhonesListAddAllValidAndNoRepeated() { var contact = ContactEntityObjectMother.Random(); var phone1 = PhoneValueObjectObjectMother.Random(); var phone2 = PhoneValueObjectObjectMother.Random(); contact.AddPhoneNumbers(new List <Tuple <PhoneType, string> > { new Tuple <PhoneType, string>(phone1.PhoneType, phone1.PhoneNumber), new Tuple <PhoneType, string>(phone2.PhoneType, phone2.PhoneNumber), null, new Tuple <PhoneType, string>(phone1.PhoneType, phone1.PhoneNumber), new Tuple <PhoneType, string>(phone2.PhoneType, phone2.PhoneNumber) }); Assert.AreEqual(2, contact.PhoneNumbers.Count); Assert.IsTrue(contact.PhoneNumbers.Contains(phone1)); Assert.IsTrue(contact.PhoneNumbers.Contains(phone2)); }