public async Task DeleteByIdAsync_Deletes_AppointmentAsync()
        {
            using (var dbContext = AppointmentDbContextInMemory.CreateInMemoryDbContext())
            {
                //Arrange
                var appointment1 = new Appointment {
                    Id = 9, Title = "test1"
                };
                var appointment2 = new Appointment {
                    Id = 10, Title = "test2"
                };
                var appointment3 = new Appointment {
                    Id = 11, Title = "test3"
                };

                dbContext.Appointments.Add(appointment1);
                dbContext.Appointments.Add(appointment2);
                dbContext.Appointments.Add(appointment3);
                dbContext.SaveChanges();

                //Act
                var sut = new AppointmentRepository(dbContext);
                await sut.DeleteByIdAsync(9, It.IsAny <CancellationToken>());

                var result = sut.GetByIdAsync(9, It.IsAny <CancellationToken>());

                //Assert
                Assert.Null(result.Result);
            }
        }
Example #2
0
        public async Task <Unit> Handle(DeleteAppointmentByIdCommand request, CancellationToken cancellationToken)
        {
            await appointmentRepository.DeleteByIdAsync(request.Id, cancellationToken);

            return(Unit.Value);
        }