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