public async Task GetAllBoardsAsync_HandleEmptyResultSet_Success() { var schedulingRepositoryMock = new Mock <ISchedulingRepository>(); schedulingRepositoryMock.Setup(m => m.FetchBoardsAsync(null)) .ReturnsAsync(Enumerable.Empty <SchedulingBoard>().ToList); var unitUnderTest = new SchedulingBoardController(schedulingRepositoryMock.Object); var result = await unitUnderTest.GetAllBoardsAsync(); Assert.IsType <OkObjectResult>(result); Assert.Empty(((ObjectResult)result).Value as IEnumerable <SchedulingBoard> ?? throw new InvalidCastException()); }
public async Task GetBoardAsync_HandleResult_Success() { var id = Guid.NewGuid(); var schedulingBoard = new SchedulingBoard(id); var schedulingRepositoryMock = new Mock <ISchedulingRepository>(); schedulingRepositoryMock.Setup(m => m.FetchBoardAsync(id)).ReturnsAsync(schedulingBoard); var unitUnderTest = new SchedulingBoardController(schedulingRepositoryMock.Object); var result = await unitUnderTest.GetBoardAsync(id); Assert.IsType <OkObjectResult>(result); Assert.Equal(id, (((ObjectResult)result).Value as SchedulingBoard)?.Id); }
public async Task GetAllBoardsAsync_HandleResponseSet_Success() { var schedulingRepositoryMock = new Mock <ISchedulingRepository>(); schedulingRepositoryMock.Setup(m => m.FetchBoardsAsync(null)) .ReturnsAsync( new List <SchedulingBoard> { new SchedulingBoard(Guid.NewGuid()) }); var unitUnderTest = new SchedulingBoardController(schedulingRepositoryMock.Object); var result = await unitUnderTest.GetAllBoardsAsync(); Assert.IsType <OkObjectResult>(result); }
public async Task GetBoardAsync_IdIsNotSpecified_SuccessReturnsBadRequest() { var schedulingRepositoryMock = new Mock <ISchedulingRepository>(); var unitUnderTest = new SchedulingBoardController(schedulingRepositoryMock.Object); var result = await unitUnderTest.GetBoardAsync(default);