Beispiel #1
0
        public async Task Should_return_not_found()
        {
            var id          = 7;
            var beerService = MockBeerService();

            var sut = new BeersController(
                beerService.Object
                );

            var result = await sut.GetBeer(id);

            var actionResult = Assert.IsType <NotFoundResult>(result.Result);

            beerService.Verify(x => x.GetById(It.IsAny <long>()), Times.Once);

            actionResult.Should().NotBeNull();
            actionResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
Beispiel #2
0
        public async Task Should_get_beer_by_id_when_exists()
        {
            var id          = 1;
            var beerService = MockBeerService(Beers);

            var sut = new BeersController(
                beerService.Object
                );

            var result = await sut.GetBeer(id);

            var actionResult = Assert.IsType <ActionResult <BeerDto> >(result);

            beerService.Verify(x => x.GetById(It.IsAny <long>()), Times.Once);

            actionResult.Value.Should().NotBeNull();
            actionResult.Value.Id.Should().Be(id);
            actionResult.Result.Should().BeNull();
        }