Exemple #1
0
        public async Task GetSummaryOfPlantEventReturnsNotFoundAndCorrectContentTypeIfResourceNotFoundExceptionOccured()
        {
            // Given
            A.CallTo(() => _fakeQuery.Summary(A <Guid> .Ignored, A <DateTime?> .Ignored, A <DateTime?> .Ignored))
            .Returns(Task.FromResult <IEnumerable <PlantEventOccurenceSummaryModel> >(null));

            // When
            HttpResponseMessage response = await Client.GetAsync(EndPointFactory.EventsSummaryEndpoint());

            // Then
            response.StatusCode.Should().Be(HttpStatusCode.NotFound);
            response.Content.Headers.ContentType.ToString().Should().Be("application/problem+json; charset=utf-8");
            A.CallTo(() => _fakeQuery.Summary(A <Guid> .Ignored, A <DateTime?> .Ignored, A <DateTime?> .Ignored))
            .MustHaveHappenedOnceExactly();
        }
        public async Task <ActionResult <IEnumerable <PlantEventOccurenceSummaryModel> > > GetSummary([FromRoute] Guid plantId,
                                                                                                      [FromQuery] DateTime?fromDate = null,
                                                                                                      [FromQuery] DateTime?toDate   = null)
        {
            IEnumerable <PlantEventOccurenceSummaryModel> events = await _queries.Summary(plantId, fromDate, toDate);

            if (events is null)
            {
                return(NotFound());
            }

            return(Ok(_mapper.Map <IEnumerable <PlantEventOccurenceSummaryViewModel> >(events)));
        }