예제 #1
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());
        }
예제 #2
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);
        }
예제 #3
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);
        }