public async Task GetExamplesAsync_ExamplesDoNotExist_ReturnsNotFound( [Frozen] Mock <IExampleService> exampleServiceMock, ExampleController sut) { exampleServiceMock.Setup(x => x.GetExamplesAsync()).Returns(Task.FromResult <IEnumerable <Example> >(null)); var result = await sut.GetExamplesAsync(); var notfoundResult = result.Result as NotFoundResult; notfoundResult.StatusCode.Should().Be(StatusCodes.Status404NotFound); }
public async Task GetExamplesAsync_ExamplesExist_ReturnsOkExamples( [Frozen] Mock <IExampleService> exampleServiceMock, IEnumerable <Example> examples, ExampleController sut) { exampleServiceMock.Setup(x => x.GetExamplesAsync()).Returns(Task.FromResult(examples)); var result = await sut.GetExamplesAsync(); var okObjectResult = result.Result as OkObjectResult; okObjectResult.StatusCode.Should().Be(StatusCodes.Status200OK); okObjectResult.Value.Should().BeEquivalentTo(examples); }