Exemple #1
0
        public void AddressTypeRoundtipsToDatabase()
        {
            int    newPersonId = 0;
            var    address     = CreateAddress(ContactType.Personal);
            Person person      = SimplePeopleTests.CreatePerson();

            person.HomeAddress = address;
            address            = CreateAddress(ContactType.Business);
            person.WorkAddress = address;

            using (new EFUnitOfWorkFactory().Create())
            {
                PeopleRepository peopleRepository = new PeopleRepository();
                peopleRepository.Add(person);
            }
            newPersonId = person.Id;

            newPersonId.Should().BeGreaterThan(0);

            ContactManagerContext context = new ContactManagerContext();
            var check = context.People.First(x => x.Id == newPersonId);

            check.Id.Should().Be(newPersonId);
            check.HomeAddress.ContactType.Should().Be(ContactType.Personal);
            check.WorkAddress.ContactType.Should().Be(ContactType.Business);
        }
        public void EmailAddressTypeRoundtipsToDatabase()
        {
            int         newPersonId = 0;
            ContactType type        = ContactType.Personal;
            var         address     = CreateEmailAddress();

            address.ContactType = type;
            Person person = SimplePeopleTests.CreatePerson();

            person.EmailAddresses.Add(address);

            using (var uwo = new EFUnitOfWorkFactory().Create())
            {
                PeopleRepository peopleRepository = new PeopleRepository();
                peopleRepository.Add(person);
            }
            newPersonId = person.Id;

            newPersonId.Should().BeGreaterThan(0);

            ContactManagerContext context = new ContactManagerContext();
            var check = context.People.Include("EmailAddresses").First(x => x.Id == newPersonId);

            check.Id.Should().Be(newPersonId);
            check.EmailAddresses.First().ContactType.Should().Be(type);
        }