コード例 #1
0
        public void UpdateDoctor_AppliedValuesAreStoredInDataStore()
        {
            using (var dc = new DoctorContext())
            {
                var doctor = new Doctor
                {
                    Firstname = "Paul",
                    Lastname  = "Johnson",
                    Phone     = "+33 6 67 81 09 58",
                    Specialty = null,
                    User      = (from u in dc.DataContext.Users where u.Role.Name == "visiteur" select u).First(),
                    Office    = (from o in dc.DataContext.Offices select o).First()
                };

                dc.CreateDoctor(doctor);

                const string newFirstName = "Dave",
                             newLastName  = "Scott",
                             newPhone     = "+33 7 58 42 15 20";

                doctor.Firstname = newFirstName;
                doctor.Lastname  = newLastName;
                doctor.Phone     = newPhone;

                // Act
                dc.UpdateDoctor(doctor);

                // Assert
                dc.DataContext.Entry(doctor).Reload();

                Assert.AreEqual(newPhone, doctor.Phone);
                Assert.AreEqual(newFirstName, doctor.Firstname);
                Assert.AreEqual(newLastName, doctor.Lastname);
            }
        }