Beispiel #1
0
        public void UpdateVisit_AppliedValuesAreStoredInDataStore()
        {
            using (var vc = new VisitContext())
            {
                // Arrange
                var visit = new Visit
                {
                    VisitDate          = DateTime.Now,
                    Appointment        = Convert.ToSByte(true),
                    ArrivingTime       = DateTime.Now.TimeOfDay,
                    StartTimeInterview = DateTime.Now.TimeOfDay,
                    DepartureTime      = DateTime.Now.TimeOfDay,
                    User   = (from v in vc.DataContext.Users where v.Id == 1 select v).First(),
                    Doctor = (from d in vc.DataContext.Doctors where d.User.Id == 1 select d).First()
                };

                vc.CreateVisit(visit);

                // new values
                var        newDate        = new DateTime(2018, 04, 27);
                const bool newAppointment = false;
                var        newTime        = new TimeSpan(19, 20, 0);
                var        newUser        = (from v in vc.DataContext.Users where v.Id == 2 select v).First();
                var        newDoctor      = (from d in vc.DataContext.Doctors where d.User.Id == 2 select d).First();

                visit.VisitDate          = newDate;
                visit.Appointment        = Convert.ToSByte(newAppointment);
                visit.ArrivingTime       = newTime;
                visit.StartTimeInterview = newTime;
                visit.DepartureTime      = newTime;
                visit.User   = newUser;
                visit.Doctor = newDoctor;

                // Act
                vc.UpdateVisit(visit);

                // Assert
                vc.DataContext.Entry(visit).Reload();

                Assert.AreEqual(newDate, visit.VisitDate);
                Assert.AreEqual(newAppointment, Convert.ToBoolean(visit.Appointment));
                Assert.AreEqual(newTime, visit.ArrivingTime);
                Assert.AreEqual(newTime, visit.StartTimeInterview);
                Assert.AreEqual(newTime, visit.DepartureTime);
                Assert.AreEqual(newUser, visit.User);
                Assert.AreEqual(newDoctor, visit.Doctor);
            }
        }