public async Task GetListReturnsNotFoundIfPlantDoesNotExist() { // Given A.CallTo(() => _fakeQuery.GetByPlant(A <Guid> .Ignored)).Returns(Task.FromResult <IEnumerable <Event> >(null)); // When HttpResponseMessage response = await Client.GetAsync(EndPointFactory.ListEndpoint()); // Then response.StatusCode.Should().Be(HttpStatusCode.NotFound); response.Content.Headers.ContentType.ToString().Should().Be("application/problem+json; charset=utf-8"); A.CallTo(() => _fakeQuery.GetByPlant(A <Guid> .Ignored)).MustHaveHappenedOnceExactly(); }
public async Task <ActionResult <IEnumerable <PlantEventsIndexViewModel> > > Get([FromRoute] Guid plantId) { IEnumerable <Event> events = await _queries.GetByPlant(plantId); if (events is null) { return(NotFound()); } return(Ok(_mapper.Map <IEnumerable <PlantEventsIndexViewModel> >(events))); }