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); } }
public void AddNewDoctor_ThrowsException_WhenPhoneIsNull() { using (var dc = new DoctorContext()) { var doctor = new Doctor { Firstname = "Paul", Lastname = "Johnson", Phone = null, 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); } }
public void AddNewDoctor_ThrowsException_WhenFirstNameIsEmpty() { using (var dc = new DoctorContext()) { var doctor = new Doctor { Firstname = "", Lastname = "David", 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); } }
public void AddNewDoctor_DoctorIsStoredInDataStore() { 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); var exists = dc.DataContext.Doctors.Any(c => c.Id == doctor.Id); Assert.IsTrue(exists); } }