public void ShouldDeleteAppointment() { var testId = 34; var sqlMock = new Mock <ISqlOrm>(); sqlMock.Setup(m => m.DeleteAsync(testId, "appointment")).ReturnsAsync(43); var repo = new AppointmentRepository(sqlMock.Object); var result = repo.DeleteAsync(testId).Result; Assert.Equal(43, result); }
public void Given_AppointmentRepository_When_DeletingAnAppointment_Then_TheAppointmentShouldBeProperlyRemoved() { 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 await repository.DeleteAsync(appointment); //Assert Assert.AreEqual(repository.GetAllAsync().Result.Count, 0); }); }
public async Task <IResult> DeleteAsync(long appointmentId) { var appointment = await AppointmentRepository.SelectAsync <AppointmentEntity>(appointmentId); if (appointment == null) { return(ErrorResult(Texts.AppointmentNotFound)); } if (!appointment.canBeDeleted()) { return(ErrorResult(Texts.AppointmentCanNotBeDeleted)); } await AppointmentRepository.DeleteAsync(appointmentId); await DatabaseUnitOfWork.SaveChangesAsync(); return(SuccessDataResult(appointmentId)); }
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); }); }