public async Task GetAsync_ShouldReturnNotFoundGivenNoMatchingId() { _basicService.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(default(Basic)); var controller = new BasicController(_basicService.Object); var result = await controller.GetAsync(It.IsAny <int>()); result.Result.Should().BeOfType <NotFoundResult>(); }
public async Task GetAsync_ShoulrReturnBasicGivenId() { var list = new Fixture().CreateMany <Basic>(); var firstBasic = list.FirstOrDefault(); _basicService.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(firstBasic); var controller = new BasicController(_basicService.Object); var actionResult = await controller.GetAsync(It.IsAny <int>()); actionResult.Should().BeOfType <ActionResult <Basic> >(); var result = actionResult.Result as OkObjectResult; result.Value.Should().Be(firstBasic); }