public async Task GetTimeSlotDetailsAsync_HandleResult_Success() { var id = Guid.NewGuid(); var timeSlot = TimeSlotFactory.CreateTimeSlot(TimeSlotType.Control); var schedulingRepositoryMock = new Mock <ISchedulingRepository>(); schedulingRepositoryMock.Setup(m => m.FetchTimeSlotAsync(id)).ReturnsAsync(timeSlot); var unitUnderTest = new TimeSlotController(schedulingRepositoryMock.Object); var result = await unitUnderTest.GetTimeSlotDetailsAsync(id); Assert.IsType <OkObjectResult>(result); Assert.Equal(timeSlot.Id, (((ObjectResult)result).Value as TimeSlot)?.Id); }
public async Task TestGetNoResults() { // Arrange var models = new List <TimeSlotDTO>(); var mockService = new Mock <ITimeSlotService>(); mockService .Setup(x => x.GetAllAsDTOAsync()) .ReturnsAsync(models); var controller = new TimeSlotController(mockService.Object); // Act var result = await controller.Get(); // Assert var actionResult = Assert.IsAssignableFrom <OkObjectResult>(result.Result); var modelResult = Assert.IsAssignableFrom <IEnumerable <TimeSlotDTO> >(actionResult.Value); Assert.Empty(modelResult); }
public async Task GetTimeSlotDetailsAsync_IdIsNotSpecified_SuccessReturnsBadRequest() { var schedulingRepositoryMock = new Mock <ISchedulingRepository>(); var unitUnderTest = new TimeSlotController(schedulingRepositoryMock.Object); var result = await unitUnderTest.GetTimeSlotDetailsAsync(default);