示例#1
0
        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();
        }
示例#2
0
        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)));
        }