コード例 #1
0
        public static Person CreatePerson()
        {
            Person person = new Person()
            {
                FirstName = "Imar", LastName = "Spaanjaars", Type = PersonType.Colleague, DateOfBirth = DateTime.Now.AddYears(-20)
            };

            person.HomeAddress = AddressTests.CreateAddress(ContactType.Personal);
            person.WorkAddress = AddressTests.CreateAddress(ContactType.Business);
            return(person);
        }
        private static Person CreatePerson()
        {
            var person = new Person
            {
                FirstName   = "Imar",
                LastName    = "Spaanjaars",
                DateOfBirth = new DateTime(1971, 8, 9),
                Type        = PersonType.Friend
            };

            person.HomeAddress = AddressTests.CreateAddress(ContactType.Personal);
            person.WorkAddress = AddressTests.CreateAddress(ContactType.Business);
            return(person);
        }
コード例 #3
0
        public void CanExecuteQueryAgainstDataContext()
        {
            string lastName = Guid.NewGuid().ToString().Substring(0, 25);
            var    context  = DataContextFactory.GetDataContext();
            var    person   = new Person {
                FirstName = "Imar", LastName = lastName, DateOfBirth = new DateTime(1971, 8, 9), DateCreated = DateTime.Now, DateModified = DateTime.Now, Type = PersonType.Colleague, HomeAddress = AddressTests.CreateAddress(ContactType.Personal), WorkAddress = AddressTests.CreateAddress(ContactType.Business)
            };

            context.People.Add(person);
            context.SaveChanges();

            var personCheck = context.People.First(x => x.LastName == lastName);

            personCheck.Should().NotBeNull();
        }
コード例 #4
0
        public void CanAddPersonUsingContactManagerContext()
        {
            var person = new Person {
                FirstName = "Imar", LastName = "Spaanjaars", DateOfBirth = new DateTime(1971, 8, 9), DateCreated = DateTime.Now, DateModified = DateTime.Now, Type = PersonType.Colleague, HomeAddress = AddressTests.CreateAddress(ContactType.Personal), WorkAddress = AddressTests.CreateAddress(ContactType.Business)
            };
            var context = new ContactManagerContext();

            context.People.Add(person);
            context.SaveChanges();
        }