public async void GetWidgetWillReturnNotFoundWhenNull() { _mockedRepository.Setup(x => x.GetAllAsync()).ReturnsAsync(() => null); var myController = new WidgetsController(_mockedRepository.Object); var actionResult = await myController.GetWidgets(); Assert.NotNull(actionResult); Assert.IsType <NotFoundResult>(actionResult.Result); }
public void GetWidgets_CorrectResponse() { var result = controller.GetWidgets() as ObjectResult; Assert.NotNull(result); var widgets = result.Value as Widget[]; Assert.NotNull(widgets); Assert.Equal(3, widgets.Length); }
public async void GetWidgetsWillReturnOkResult() { _mockedRepository.Setup(repo => repo.GetAllAsync()).ReturnsAsync(_widgets); var actionResult = await _widgetsController.GetWidgets(); var result = actionResult.Result as OkObjectResult; Assert.NotNull(result); Assert.IsType <OkObjectResult>(result); Assert.Equal(_widgets, result.Value); }