public void DeleteAddress()
        {
            //Arrange
            var address = Repository.GetFirst <Address>();

            //Act
            Repository.Delete(address);
            Repository.Save();

            //Assert
            Assert.False(address.IsActive);
            Assert.NotNull(address.ModifiedDateTime);
            Assert.True(address.ModifiedDateTime.Value.Date == DateTime.Today);
        }
        public void CreatePersonWithAddresses()
        {
            //Arrange
            var personSearch = MockDataFactory.GetPersonSearch();

            Repository.Create(personSearch);
            Repository.Save();

            //Act
            var person = MockDataFactory.GetPerson(personSearch.Id);

            Repository.Create(person);
            Repository.Save();

            var addresses = MockDataFactory.GetAddresses(person.Id);

            foreach (var address in addresses)
            {
                Repository.Create(address);
                Repository.Save();
            }

            var savedPerson    = Repository.GetFirst <Person>(x => x.Id == person.Id);
            var savedAddresses = Repository.Get <Address>(x => x.PersonId == person.Id);

            //Assert
            Assert.Equal(person.Id, savedPerson.Id);
            Assert.Equal(person.FirstName, savedPerson.FirstName);
            Assert.Equal(person.LastName, savedPerson.LastName);
            Assert.Equal(person.Alias, savedPerson.Alias);
            Assert.Equal(person.AgeRange, savedPerson.AgeRange);
            Assert.Equal(addresses.Count(), savedAddresses.Count());
            Assert.Equal(addresses.Count(), savedPerson.Addresses.Count());

            foreach (var savedAddress in savedAddresses)
            {
                var anyAddress = addresses.Any(x => x.Id == savedAddress.Id);
                Assert.True(anyAddress);
            }
        }
示例#3
0
        public void UpdateAddress()
        {
            //Arrange
            var address = Repository.GetFirst <Address>();

            address.Address1     = $"Updated-{address.Address1}";
            address.Address2     = $"Updated-{address.Address2}";
            address.City         = $"Updated-{address.City}";
            address.State        = $"Updated-{address.State}";
            address.Zip          = $"Updated-{address.Zip}";
            address.Plus4        = $"Updated-{address.Plus4}";
            address.IsCurrent    = !address.IsCurrent;
            address.IsHistorical = !address.IsHistorical;
            address.Accuracy     = $"Updated-{address.Accuracy}";

            //Act
            Repository.Update(address);
            Repository.Save();

            //Assert
            Assert.NotNull(address.ModifiedDateTime);
            Assert.True(address.ModifiedDateTime.Value.Date == DateTime.Today);
        }