public void ItShouldReturn204HttpCode()
        {
            var response = new GetAllBeersResponse
            {
                Beers = new List <Beer>()
            };

            var presenter = new ApiGetAllBeersPresenter();

            presenter.Present(response);

            var viewModel = presenter.ViewModel;

            Assert.Equal(204, viewModel.HttpCode);
        }
Example #2
0
        public ActionResult GetAllBeers([FromQuery] GetAllBeersRequest request)
        {
            var useCase = new GetAllBeers(_catalog);

            var presenter = new ApiGetAllBeersPresenter();

            useCase.Execute(request, presenter);

            var viewModel = presenter.ViewModel;

            if (viewModel.HttpCode == 200)
            {
                return(Ok(viewModel));
            }
            return(NoContent());
        }
        public void ItShouldReturn200HttpCode()
        {
            var response = new GetAllBeersResponse
            {
                Beers = new List <Beer>
                {
                    new Beer(Guid.NewGuid(), "Label", "Description", 0)
                }
            };

            var presenter = new ApiGetAllBeersPresenter();

            presenter.Present(response);

            var viewModel = presenter.ViewModel;

            Assert.Equal(200, viewModel.HttpCode);
        }
        public void ItShouldReturnOneLastItemsBeer()
        {
            var response = new GetAllBeersResponse
            {
                Beers = new List <Beer>
                {
                    new Beer(Guid.NewGuid(), "Label", "Description", 5),
                    new Beer(Guid.NewGuid(), "Label", "Description", 0),
                    new Beer(Guid.NewGuid(), "Label", "Description", 0)
                }
            };

            var presenter = new ApiGetAllBeersPresenter();

            presenter.Present(response);

            var viewModel = presenter.ViewModel;

            var availableBeers = viewModel.Data.Where(b => b.LastItems).ToList();

            Assert.Single(availableBeers);
        }
        public void ItShouldReturnTheSameData()
        {
            var response = new GetAllBeersResponse
            {
                Beers = new List <Beer>
                {
                    new Beer(Guid.NewGuid(), "Label", "Description", 100)
                }
            };

            var presenter = new ApiGetAllBeersPresenter();

            presenter.Present(response);

            var viewModel = presenter.ViewModel;

            var responseBeers  = response.Beers.ToList();
            var viewModelBeers = viewModel.Data.ToList();

            Assert.Equal(viewModelBeers[0].Id, responseBeers[0].Id.Value);
            Assert.Equal(viewModelBeers[0].Label, responseBeers[0].Label.Value);
            Assert.Equal(viewModelBeers[0].Description, responseBeers[0].Description.Value);
            Assert.Equal(viewModelBeers[0].Stock, responseBeers[0].Stock.Value);
        }