public void update_name_already_used() { PatientTests patientTests = new PatientTests(); Domain.Entities.Patient patientFound = this.patientService.SearchByKey(new Guid("08c9895d-d2ff-4720-8d09-5e98a0fe928f")).Result; patientFound.SetNamePhone("name 109", patientFound.Phone); var ex = Assert.Throws <Exception> (() => this.patientService.UpdatePatient(patientFound).Result); Assert.Contains("já existe registro com este nome", ex.Message); }
public void update_name_corrected() { PatientTests patientTests = new PatientTests(); Domain.Entities.Patient patientFound = this.patientService.SearchByKey(new Guid("08c9895d-d2ff-4720-8d09-5e98a0fe928f")).Result; patientFound.SetNamePhone("name 110 _", patientFound.Phone); var patientUpdated = this.patientService.UpdatePatient(patientFound).Result; Assert.Equal(1, patientUpdated); }
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)); }
public static Mock <IPatientRepository> FakePatientRepository() { Massoterapia.Domain.Tests.PatientTests patientTests = new Domain.Tests.PatientTests(); Domain.Entities.Patient patientCreatedFakefromDB = patientTests.loadPatientFromFile("patientFull_Create_fromDB.json", "", ""); Domain.Entities.Patient patientFakefromDB = patientTests.loadPatientFromFile("patientFull_fromDB.json", "", ""); var patientViewModel = configurations.GetUserInputModelCriation(); Domain.Entities.Patient patientTobeSaved = new Domain.Entities.Patient( patientViewModel.Name, patientViewModel.Phone, configurations.GetSchedule(patientViewModel.ScheduleData.StartdDate, 50) ); mockPatientRepository.Setup(repo => repo.Insert(It.IsAny <Domain.Entities.Patient>())).ReturnsAsync(patientCreatedFakefromDB); IList <Domain.Entities.Patient> PatientList = new List <Domain.Entities.Patient>(); patientFakefromDB.SetNamePhone("usuario", "11998877666"); PatientList.Add(patientFakefromDB); mockPatientRepository.Setup(repo => repo.QueryByNameOrPhone("usuario", "11998877666")).ReturnsAsync(PatientList); List <DateTime> dateRange = new List <DateTime>(); dateRange.Add(new DateTime(2021, 05, 11, 09, 10, 0)); dateRange.Add(new DateTime(2021, 05, 11, 10, 50, 0)); mockPatientRepository.Setup(repo => repo.QueryLikeNamePhoneScheduledateRange(null, null, dateRange)).ReturnsAsync(PatientList); Guid blogGuid = new Guid("ca3aa909-c935-4c9f-b304-7d744dbe050e"); mockPatientRepository.Setup(repo => repo.Query(blogGuid)).ReturnsAsync(patientTobeSaved); return(mockPatientRepository); }