コード例 #1
0
        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)));
        }
コード例 #2
0
ファイル: IntegrationTests.cs プロジェクト: JachuPL/Spice
        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();
        }