Exemplo n.º 1
0
        public async Task GetAllProductOptionsByProductId_Success_ReturnsProductOptions()
        {
            //Arrange
            var product        = _fixture.Create <Product>();
            var productOptions = _fixture.CreateMany <ProductOption>(3);

            _productRepo.Setup(x => x.GetByIdAsync(It.IsAny <Guid>())).ReturnsAsync(product);
            _productOptionRepo.Setup(x => x.GetAllByProductIdAsync(product.Id)).ReturnsAsync(productOptions);

            //Act
            var result = await _productOptionService.GetAllProductOptionsByProductIdAsync(product.Id);

            //Assert
            result.Should().NotBeNull().And.Subject.Should().HaveCount(3);
        }
        public async Task <IActionResult> GetOptions(Guid productId)
        {
            var productOptions = await _productOptionService.GetAllProductOptionsByProductIdAsync(productId);

            var productOptionsDto = _mapper.Map <IEnumerable <ProductOption>, IEnumerable <ProductOptionDto> >(productOptions);

            return(Ok(productOptionsDto));
        }