public void GetWidgetTest() { var wc = new WidgetsController(); var result = wc.GetWidget("bed09fd4-a977-47b7-88aa-27d32881e50d"); Assert.IsNotNull(result, "No widget found"); }
public async void GetWidgetByIdWillReturnNotFoundWhenWidgetIsNull() { _mockedRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(() => null); var myController = new WidgetsController(_mockedRepository.Object); var actionResult = await myController.GetWidget(It.IsAny <int>()); Assert.NotNull(actionResult); Assert.IsType <NotFoundResult>(actionResult.Result); }
public async void GetWidgetByIdWillReturnOkResult() { _mockedRepository.Setup(x => x.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(_widgets.First); var myController = new WidgetsController(_mockedRepository.Object); var actionResult = await myController.GetWidget(It.IsAny <int>()); OkObjectResult result = actionResult.Result as OkObjectResult; Assert.NotNull(result); Assert.IsType <OkObjectResult>(result); Assert.Equal(_widgets.First(), result.Value); }