Ejemplo n.º 1
0
        public async Task <IActionResult> GetProduct(GetProductRequest request)
        {
            var response = await _getProductHandler.HandleAsync(request);

            var result = MakeActionResult(response);

            return(result);
        }
Ejemplo n.º 2
0
        public async Task return_null_when_not_found_document()
        {
            //Arrange
            _productRepository.Setup(r => r.GetAsync(_guid)).Returns(Task.FromResult((Product)null));
            var query = new GetProduct();

            //Act
            var handler = new GetProductHandler(_productRepository.Object, _logger.Object);
            var result  = await handler.HandleAsync(query);

            //Assert
            Assert.Null(result);
        }
Ejemplo n.º 3
0
        public async Task return_expected_result()
        {
            //Arrange
            var product = new Product(_guid, "", "", 1, _guid);

            _productRepository.Setup(r => r.GetAsync(_guid)).ReturnsAsync(product);
            var query = new GetProduct();

            query.Id = _guid;

            //Act
            var handler = new GetProductHandler(_productRepository.Object, _logger.Object);
            var result  = await handler.HandleAsync(query);

            //Assert
            Assert.NotNull(result);
            Assert.Equal(product.Id, result.Id);
            Assert.Equal(product.CategoryId, result.CategoryId);
        }