コード例 #1
0
        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);
            });
        }
コード例 #3
0
        public async Task <ActionResult> CreateDoctor([FromBody] DoctorModel doctor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            MD5    md5Hash      = MD5.Create();
            string passwordHash = PasswordHashMd5.GetMd5Hash(md5Hash, doctor.Password);

            var instance = Doctor.Create(doctor.FirstName, doctor.LastName, doctor.Email, passwordHash, doctor.PhoneNumber, doctor.Description, doctor.Speciality, doctor.Hospital, doctor.City, doctor.Address);

            try
            {
                var newDoctor = await _repository.AddAsync(instance);

                if (newDoctor == null)
                {
                    return(BadRequest(new ApiResponse {
                        Status = false
                    }));
                }
                return(CreatedAtRoute("GetDoctorRoute", new { id = newDoctor.DoctorId },
                                      new ApiResponse {
                    Status = true, Doctor = newDoctor
                }));
            }
            catch
            {
                return(BadRequest(new ApiResponse {
                    Status = false
                }));
            }
        }
コード例 #4
0
 private void CreateDoctors()
 {
     Doctors = new ObservableCollection <Doctor>();
     Doctors.Add(Doctor.Create(Id: 1, Name: "Stomatologist"));
     Doctors.Add(Doctor.Create(Id: 2, Name: "Ophthalmologist"));
     Doctors.Add(Doctor.Create(Id: 3, Name: "Surgeon"));
 }
    public static Doctor Create(int Id, string Name)
    {
        Doctor doctor = Doctor.Create();

        doctor.Id   = Id;
        doctor.Name = Name;
        return(doctor);
    }
コード例 #6
0
        public void Given_BloodBankRepository_When_AddAsyncingABloodBank_Then_TheBloodBankShouldBeProperlySaved()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new BloodBankRepository(ctx);
                var doctor     = Doctor.Create("Daniel", "Oana", "*****@*****.**", "parola", "0746524459", "bla", "Cardiologie", "Sf. Spiridon", "Iasi", "Str. Vasile Lupu");
                var bloodBank  = BloodBank.Create(doctor);
                //Act
                await repository.AddAsync(bloodBank);

                //Assert
                Assert.AreEqual(repository.GetAllAsync().Result.Count, 1);
            });
        }
コード例 #7
0
        public void AddDcotor(DoctorAddViewModel doctorAddViewModel)
        {
            Doctor doctor = Doctor.Create(doctorAddViewModel.FirstName, doctorAddViewModel.LastName,
                                          doctorAddViewModel.ProfessionalTitle, doctorAddViewModel.ClinicId, doctorAddViewModel.ContactTel, doctorAddViewModel.Notes);

            //Doctor doctor = new Doctor(doctorAddViewModel.FirstName, doctorAddViewModel.LastName,
            //    doctorAddViewModel.ProfessionalTitle, doctorAddViewModel.ClinicId, doctorAddViewModel.ContactTel, doctorAddViewModel.Notes);

            doctor.JoinDate   = DateTime.Now;
            doctor.UpdateDate = DateTime.Now;

            _doctorReposiotry.Add(doctor);

            //return AutoMapper.Mapper.Map<Doctor, DoctorAddViewModel>(doctor);
        }
コード例 #8
0
        public void Given_DoctorRepository_When_ReturningADoctor_Then_TheDoctorShouldBeProperlyReturned()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new DoctorRepository(ctx);
                var doctor     = Doctor.Create("1234", "Mircea", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true);
                await repository.AddAsync(doctor);

                //Act
                var extractedDoctor = await repository.GetByIdAsync(doctor.DoctorId);

                //Assert
                Assert.AreEqual(doctor, extractedDoctor);
            });
        }
コード例 #9
0
        public void Given_DoctorRepository_When_AddAsyncingADoctor_Then_TheDoctorShouldBeProperlySaved()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new DoctorRepository(ctx);
                var doctor     = Doctor.Create("1234", "Mircea", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true);

                //Act
                await repository.AddAsync(doctor);

                //Assert
                string[] includes = { };
                Assert.AreEqual(repository.GetAllAsync(includes).Result.Count, 1);
            });
        }
コード例 #10
0
        public void Given_DoctorRepository_When_ReturningAllDoctors_Then_AllDoctorsShouldBeProperlyReturned()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new DoctorRepository(ctx);
                var doctor     = Doctor.Create("Daniel", "Oana", "*****@*****.**", "parola", "0746524459", "bla", "Cardiologie", "Sf. Spiridon", "Iasi", "Str. Vasile Lupu");
                await repository.AddAsync(doctor);

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

                //Assert
                Assert.AreEqual(count, 1);
            });
        }
コード例 #11
0
        public void Given_DoctorRepository_When_ReturningADoctor_Then_TheDoctorShouldBeProperlyReturned()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new DoctorRepository(ctx);
                var doctor     = Doctor.Create("Daniel", "Oana", "*****@*****.**", "parola", "0746524459", "bla", "Cardiologie", "Sf. Spiridon", "Iasi", "Str. Vasile Lupu");
                await repository.AddAsync(doctor);

                //Act
                var extractedDoctor = await repository.GetByIdAsync(doctor.DoctorId);

                //Assert
                Assert.AreEqual(doctor, extractedDoctor);
            });
        }
コード例 #12
0
        public void Given_PatientHistoryRepository_When_AddAsyncingAPatientHistory_Then_ThePatientHistoryShouldBeProperlySaved()
        {
            var doctor  = Doctor.Create("Daniel", "Oana", "*****@*****.**", "parola", "0746524459", "ads", "Cardiologie", "Sf. Spiridon", "Iasi", "Str. Vasile Lupu");
            var patient = Patient.Create("Roland", "Iordache", "*****@*****.**", "asfdsdssd", "Iasi", new DateTime(1996, 02, 10), "0746524459", null);

            RunOnDatabase(async ctx => {
                //Arrange
                var repository     = new PatientHistoryRepository(ctx);
                var patientHistory = PatientHistory.Create(patient, doctor, "Paracetamol", "Febra", "Odihna", new DateTime(1996, 02, 10));

                //Act
                await repository.AddAsync(patientHistory);

                //Assert
                Assert.AreEqual(repository.GetAllAsync().Result.Count, 1);
            });
        }
コード例 #13
0
        public void Given_FeedbackRepository_When_ReturningAFeedback_Then_TheFeedbackShouldBeProperlyReturned()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new FeedbackRepository(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 feedback   = Feedback.Create("OK", patient.PatientId, doctor.DoctorId, 5, new DateTime());
                await repository.AddAsync(feedback);

                //Act
                var extractedFeedback = await repository.GetByIdAsync(feedback.FeedbackId);

                //Assert
                Assert.AreEqual(feedback, extractedFeedback);
            });
        }
コード例 #14
0
        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);
            });
        }
コード例 #15
0
        public void Given_PatientHistoryRepository_When_AddAsyncingAPatientHistory_Then_ThePatientHistoryShouldBeProperlySaved()
        {
            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);

            RunOnDatabase(async ctx => {
                //Arrange
                var repository     = new PatientHistoryRepository(ctx);
                var patientHistory = PatientHistory.Create(patient.PatientId);

                //Act
                await repository.AddAsync(patientHistory);

                //Assert
                string[] includes = { " " };
                Assert.AreEqual(repository.GetAllAsync(includes).Result.Count, 1);
            });
        }
コード例 #16
0
        public void Given_PatientHistoryRepository_When_ReturningAPatientHistory_Then_ThePatientHistoryShouldBeProperlyReturned()
        {
            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);


            RunOnDatabase(async ctx => {
                //Arrange
                var repository     = new PatientHistoryRepository(ctx);
                var patientHistory = PatientHistory.Create(patient.PatientId);
                await repository.AddAsync(patientHistory);

                //Act
                var extractedPatientHistory = await repository.GetByIdAsync(patientHistory.HistoryId);

                //Assert
                Assert.AreEqual(patientHistory, extractedPatientHistory);
            });
        }
コード例 #17
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);
            });
        }
コード例 #18
0
        public void Given_DoctorRepository_When_EditingADoctor_Then_TheDoctorShouldBeProperlyEdited()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new DoctorRepository(ctx);
                var doctor     = Doctor.Create("1234", "Mircea", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true);
                await repository.AddAsync(doctor);

                var firstName = doctor.FirstName;

                doctor.Update("1234", "Axinte", "Cartarescu", "*****@*****.**", "parola", "0746524459", "blasdadsadsada", "Cardiologie", "Sf. Spiridon", "Iasi", "Romania", "Str. Vasile Lupu", true);

                var newFirstName = doctor.FirstName;

                //Act
                await repository.UpdateAsync(doctor);

                //Assert
                Assert.AreNotEqual(firstName, newFirstName);
            });
        }
コード例 #19
0
        public void Given_DoctorRepository_When_EditingADoctor_Then_TheDoctorShouldBeProperlyEdited()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new DoctorRepository(ctx);
                var doctor     = Doctor.Create("Daniel", "Oana", "*****@*****.**", "parola", "0746524459", "bla", "Cardiologie", "Sf. Spiridon", "Iasi", "Str. Vasile Lupu");
                await repository.AddAsync(doctor);

                var firstName = doctor.FirstName;

                doctor.Update("Oana", "Oana", "*****@*****.**", "parola", "0746524459", "bla", "Cardiologie", "Sf. Spiridon", "Iasi", "Str. Vasile Lupu", null, null);

                var newFirstName = doctor.FirstName;

                //Act
                await repository.UpdateAsync(doctor);

                //Assert
                Assert.AreNotEqual(firstName, newFirstName);
            });
        }
コード例 #20
0
        public void Given_BloodBankRepository_When_EditingABloodBank_Then_TheBloodBankShouldBeProperlyEdited()
        {
            RunOnDatabase(async ctx => {
                //Arrange
                var repository = new BloodBankRepository(ctx);
                var doctor     = Doctor.Create("Daniel", "Oana", "*****@*****.**", "parola", "0746524459", "bla", "Cardiologie", "Sf. Spiridon", "Iasi", "Str. Vasile Lupu");
                var bloodBank  = BloodBank.Create(doctor);
                await repository.AddAsync(bloodBank);

                //var firstName = doctor.FirstName;

                bloodBank.Update("A2", doctor);

                //var newFirstName = doctor.FirstName;

                //Act
                await repository.UpdateAsync(bloodBank);

                //Assert
                Assert.AreEqual(repository.GetAllAsync().Result[0].Types["A2"], 1);
            });
        }