public void Given_AppointmentRepository_When_EditingAnAppointment_Then_TheAppointmentShouldBeProperlyEdited()
        {
            RunOnDatabase(async ctx =>
            {
                //Arrange
                var repository = new AppointmentRepository(ctx);
                var patient    = Patient.Create("Roland", "Iordache", "*****@*****.**", "asfdsdssd", "Iasi",
                                                new DateTime(1996, 02, 10), "0746524459", null);
                var patient2 = Patient.Create("Roland", "Oana", "*****@*****.**", "asfdsdssd", "Iasi",
                                              new DateTime(1996, 02, 10), "0746524459", null);
                var doctor      = Doctor.Create("a", "b", "*****@*****.**", "adcd", "0334123123", "ads", "ads", "dsd", "dsds", "dsds");
                var appointment = Appointment.Create(new DateTime(1996, 02, 10), doctor, patient);

                await repository.AddAsync(appointment);

                var appointmentPatient = appointment.Patient;
                appointment.Update(new DateTime(1996, 02, 10), doctor, patient2);

                //Act
                await repository.UpdateAsync(appointment);

                //Assert
                Assert.AreNotEqual(appointmentPatient, appointment.Patient);
            });
        }
예제 #2
0
        public void Given_AppointmentRepository_When_EditingAnAppointment_Then_TheAppointmentShouldBeProperlyEdited()
        {
            RunOnDatabase(async ctx =>
            {
                //Arrange
                var repository = new AppointmentRepository(ctx);
                var patient    = Patient.Create("1234", "Roland", "Iordache", "*****@*****.**", "asfdsdssd", "Iasi", "Romania", new DateTime(1996, 02, 10), "0746524459", null);
                var patient2   = Patient.Create("1234", "Roland", "Iordache2", "*****@*****.**", "asfdsdssd", "Iasi", "Romania", new DateTime(1996, 02, 10), "0746524459", null);
                var doctor     = Doctor.Create("1234", "Mircea", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true);

                var appointmentInterval = AppointmentInterval.Create(3, new TimeSpan(0, 10, 0, 0), new TimeSpan(0, 11, 0, 0), doctor.DoctorId);
                var appointment         = Appointment.Create(appointmentInterval.AppointmentIntervalId, new DateTime(1996, 02, 10), doctor.DoctorId, patient.PatientId);



                await repository.AddAsync(appointment);

                var appointmentPatient = appointment.Patient;
                appointment.Update(appointmentInterval.AppointmentIntervalId, new DateTime(1996, 02, 10), doctor.DoctorId, patient2.PatientId, appointment.HaveFeedback, appointment.HaveMedicalHistory);

                //Act
                await repository.UpdateAsync(appointment);

                //Assert
                Assert.AreNotEqual(appointmentPatient, appointment.Patient);
            });
        }
        public void Given_AppointmentRepository_When_ReturningAllAppointments_Then_AllAppointmentsShouldBeProperlyReturned()
        {
            RunOnDatabase(async ctx =>
            {
                //Arrange
                var repository  = new AppointmentRepository(ctx);
                var patient     = Patient.Create("Roland", "Iordache", "*****@*****.**", "asfdsdssd", "Iasi", new DateTime(1996, 02, 10), "0746524459", null);
                var doctor      = Doctor.Create("a", "b", "*****@*****.**", "adcd", "0334123123", "ads", "ads", "dsd", "dsds", "dsds");
                var appointment = Appointment.Create(new DateTime(1996, 02, 10), doctor, patient);
                await repository.AddAsync(appointment);

                //Act
                var count = repository.GetAllAsync().Result.Count;

                //Assert
                Assert.AreEqual(count, 1);
            });
        }
        public async Task <IResult> AddAsync(AddAppointmentModel addAppointmentModel)
        {
            var appointmentEntity = AppointmentFactory.Create(addAppointmentModel);
            var appointments      = await AppointmentRepository.GetByCustomerId(addAppointmentModel.CustomerId);



            if (!appointmentEntity.canCreate(appointments))
            {
                return(ErrorResult(Texts.AppointmentCanNotBeCreated));
            }

            await AppointmentRepository.AddAsync(appointmentEntity);

            await DatabaseUnitOfWork.SaveChangesAsync();

            var appointment = await AppointmentRepository.SelectAsync <AppointmentModel>(appointmentEntity.AppointmentId);

            return(SuccessDataResult(appointment));
        }
예제 #5
0
        public void Given_AppointmentRepository_When_DeletingAnAppointment_Then_TheAppointmentShouldBeProperlyRemoved()
        {
            RunOnDatabase(async ctx =>
            {
                //Arrange
                var repository          = new AppointmentRepository(ctx);
                var patient             = Patient.Create("1234", "Roland", "Iordache", "*****@*****.**", "asfdsdssd", "Iasi", "Romania", new DateTime(1996, 02, 10), "0746524459", null);
                var doctor              = Doctor.Create("1234", "Mircea", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true);
                var appointmentInterval = AppointmentInterval.Create(3, new TimeSpan(0, 10, 0, 0), new TimeSpan(0, 11, 0, 0), doctor.DoctorId);
                var appointment         = Appointment.Create(appointmentInterval.AppointmentIntervalId, new DateTime(1996, 02, 10), doctor.DoctorId, patient.PatientId);
                await repository.AddAsync(appointment);

                //Act
                await repository.DeleteAsync(appointment.PatientId);

                //Assert
                string[] includes = { };
                Assert.AreEqual(repository.GetAllAsync(includes).Result.Count, 0);
            });
        }