示例#1
0
        public void RepositoryReal_update_patient_corrected()
        {
            PatientTests patientTests = new PatientTests();

            //Domain.Entities.Patient patientToBeUpdate = patientTests.loadPatientFromFile("patientFullCreate.json","","");
            Domain.Entities.Patient patientToBeUpdate = patientTests.loadPatientFromFile("PatientFull_real_updated_fromDB.json", "", "");

            var patientUpdated = this.patientService.UpdatePatient(patientToBeUpdate).Result;

            Assert.Equal(1, patientUpdated);
        }
示例#2
0
        public void RepositoryReal_Search_by_key_patient_corrected()
        {
            PatientTests patientTests = new PatientTests();

            Domain.Entities.Patient patientToBeSearched = patientTests.loadPatientFromFile("PatientFull_real_updated_fromDB.json", "", "");

            Domain.Entities.Patient patientFound = this.patientService.SearchByKey(patientToBeSearched.Key).Result;

            var patientSerialized = patientTests.SerializePatient(patientFound);

            Assert.Equal(patientToBeSearched.Key, patientFound.Key);
        }
示例#3
0
        public void Integration_update_patient_corrected_with_schedule_altered()
        {
            PatientTests patientTests = new PatientTests();

            string dataToReplace = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");

            Domain.Entities.Patient patientToBeUpdate = patientTests.loadPatientFromFile("PatientFull_real_updated_fromDB.json", "2021-05-01", dataToReplace);
            patientToBeUpdate.Schedules[2].SetKeyNull();

            var responseInfo0 = this.UpdatenResult(patientToBeUpdate);


            //testa o paciente ja existente, tentando alterar o horario do schedule para 20 min depois
            string dataToReplace1 = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + ":15:20";

            Domain.Entities.Patient patientToBeUpdate1 = patientTests.loadPatientFromFile("PatientFull_real_updated_fromDB.json", "2021-05-01:15:00", dataToReplace);

            var responseInfo = this.UpdatenResult(patientToBeUpdate);

            var patientUpdateResult = JsonConvert.DeserializeObject <long>(responseInfo.Content.ReadAsStringAsync().Result, settings);

            Assert.Equal(1, patientUpdateResult);
        }
示例#4
0
        public void Integration_update_patient_corrected()
        {
            PatientTests patientTests = new PatientTests();

            string dataToReplace = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");

            Domain.Entities.Patient patientToBeUpdate = patientTests.loadPatientFromFile("PatientFull_real_updated_fromDB.json", "2021-05-01", dataToReplace);
            patientToBeUpdate.Schedules[2].SetKeyNull();

            var responseInfo = this.UpdatenResult(patientToBeUpdate);
            var resultado    = responseInfo.Content.ReadAsStringAsync().Result;

            var patientUpdateResult = JsonConvert.DeserializeObject <long>(resultado, settings);

            Assert.Equal(1, patientUpdateResult);
        }
示例#5
0
        public void Integration_update_patient_fail(string name, string phone, string messageError, HttpStatusCode errorMethod)
        {
            PatientTests patientTests = new PatientTests();

            Domain.Entities.Patient patientToBeUpdate = patientTests.loadPatientFromFile("PatientFull_real_updated_fromDB.json", "", "");

            if (phone == "11999999999")
            {
                Domain.Entities.Schedule newSchedule = new Domain.Entities.Schedule(DateTime.Now.AddDays(-1), false, "", false, 50, new DateTime(), false, "--Nenhum--", "--Nenhum--", 0, 0);
                newSchedule.SetKeyNull();
                patientToBeUpdate.Schedules.Add(newSchedule);
            }
            else if (phone == "11888888888")
            {
                //schedule já existente em outro registro
                Domain.Entities.Schedule newSchedule = new Domain.Entities.Schedule(new DateTime(2021, 5, 10, 18, 30, 0, DateTimeKind.Utc), false, "", false, 50, new DateTime(), false, "--Nenhum--", "--Nenhum--", 0, 0);
                newSchedule.SetKeyNull();
                patientToBeUpdate.Schedules.Add(newSchedule);
            }
            else if (phone == "11777777777")
            {
                //tenta alterar um schedule já existente em horario já utilizado por outro registro
                Domain.Entities.Schedule newSchedule = new Domain.Entities.Schedule(new DateTime(2021, 5, 20, 18, 40, 0, DateTimeKind.Utc), false, "", false, 50, new DateTime(), false, "--Nenhum--", "--Nenhum--", 0, 0);
                patientToBeUpdate.Schedules.Add(newSchedule);
            }
            else if (phone == "11666666666")
            {
                //tenta alterar um schedule já existente em horario já utilizado por outro registro
                Domain.Entities.Schedule newSchedule = new Domain.Entities.Schedule(new DateTime(2021, 5, 20, 18, 0, 0, DateTimeKind.Utc), false, "", false, 50, new DateTime(), false, "--Nenhum--", "--Nenhum--", 0, 0);
                patientToBeUpdate.Schedules.Add(newSchedule);
            }
            else
            {
                patientToBeUpdate.SetNamePhone(name, phone);
                // .Name = name;
                //patientToBeUpdate.Phone = phone;
            }

            var responseInfo = this.UpdatenResult(patientToBeUpdate);

            var messageResult = responseInfo.Content.ReadAsStringAsync().Result;

            Assert.Equal(errorMethod, responseInfo.StatusCode);
            Assert.True(messageResult.ToLower().Contains(messageError));
        }