Ejemplo n.º 1
0
        public void Execute(GetOneBeerRequest request, IGetOneBeerPresenter presenter)
        {
            var beer = _catalog.GetOneBeer(request.Id);

            var response = new GetOneBeerResponse
            {
                Data = beer
            };

            presenter.Present(response);
        }
Ejemplo n.º 2
0
        public ActionResult <ApiGetOneBeerViewModel> GetOneBeer([FromRoute] GetOneBeerRequest request)
        {
            var useCase = new GetOneBeerUseCase(_catalog);

            var presenter = new ApiGetOneBeerPresenter();

            useCase.Execute(request, presenter);

            var vm = presenter.ViewModel;

            return(vm.HttpCode == 404 ? NotFound() : (ActionResult)Ok(vm));
        }
Ejemplo n.º 3
0
        public ActionResult GetOneBeer([FromRoute] GetOneBeerRequest request)
        {
            var useCase = new GetOneBeer(_catalog);

            var presenter = new ApiGetOneBeerPresenter();

            useCase.Execute(request, presenter);

            var viewModel = presenter.ViewModel;

            if (viewModel.HttpCode == 200)
            {
                return(Ok(viewModel));
            }
            return(NotFound());
        }
Ejemplo n.º 4
0
        public void ItShouldNotReturnRequestedBeer()
        {
            var catalogMock = new Mock <IBeerCatalog>();

            catalogMock.Setup(c => c.FindOneBeerByGuid(It.IsAny <Guid>())).Returns(
                (Guid Id) => null
                );

            _catalog = catalogMock.Object;

            var id = Guid.NewGuid();

            var request = new GetOneBeerRequest
            {
                Id = id
            };

            var getOneBeerUseCase = new GetOneBeer(_catalog);

            getOneBeerUseCase.Execute(request, this);

            Assert.Null(Response.Beer);
        }
Ejemplo n.º 5
0
        public void ItShouldReturnRequestedBeer()
        {
            var catalogMock = new Mock <IBeerCatalog>();

            catalogMock.Setup(c => c.FindOneBeerByGuid(It.IsAny <Guid>())).Returns(
                (Guid Id) => new Beer(Id, "Sample Label", "Sample Description", 0)
                );

            _catalog = catalogMock.Object;

            var id = Guid.NewGuid();

            var request = new GetOneBeerRequest
            {
                Id = id
            };

            var getOneBeerUseCase = new GetOneBeer(_catalog);

            getOneBeerUseCase.Execute(request, this);

            Assert.Equal(id, Response.Beer.Id.Value);
        }