public async Task AppointmentHandler_Put_PutAsync() { //Arrange var dateTimeNow = DateTime.Now; var command = new PutAppointmentCommand { Id = 0, Title = "testTitle", Description = "testDescription", Latitude = 50.9761276, Longitude = 5.8207892, Start = dateTimeNow, End = dateTimeNow, ClientId = 9, TenantId = 1 }; Appointment appointment = new Appointment(); var mockAppointmentRepository = new Mock<AppointmentRepository>(null); //Act mockAppointmentRepository.Setup(x => x.GetByIdAsync(command.Id, It.IsAny<CancellationToken>())).ReturnsAsync(appointment); var sut = new PutAppointmentCommandHandler(mockAppointmentRepository.Object); await sut.Handle(command, CancellationToken.None); mockAppointmentRepository.Verify(x => x.PutAsync(It.Is<Appointment>(a => a.Title == command.Title && a.Description == command.Description && a.Latitude == command.Latitude && a.Longitude == command.Longitude && a.Start == command.Start && a.End == command.End && a.ClientId == command.ClientId && a.TenantId == command.TenantId), It.IsAny<CancellationToken>()), Times.Once); mockAppointmentRepository.Verify(x => x.GetByIdAsync(command.Id, It.IsAny<CancellationToken>()),Times.Once); mockAppointmentRepository.VerifyNoOtherCalls(); }
public async Task <IActionResult> PutAppointmentById(PutAppointmentCommand command) { await mediator.Send(command); return(Ok()); }