예제 #1
0
        public async Task Create_WhenCalled_ReturnsNewProductCategory()
        {
            // Arrange
            var productCategoryDto = new ProductCategoryDto()
            {
                Description = "ProductCategoryDto 1"
            };
            var expectedProductCategoryDto = new ProductCategoryDto()
            {
                Id          = 1,
                Description = "ProductCategoryDto 1"
            };

            _mockRepository.Setup(r => r.CreateAsync(productCategoryDto)).ReturnsAsync(expectedProductCategoryDto);

            // Act
            var productCategoryResult = await _sut.CreateAsync(productCategoryDto);

            // Assert
            productCategoryResult.Should().NotBeNull();
            productCategoryResult.Should().BeEquivalentTo(expectedProductCategoryDto);
            _mockRepository.Verify(r => r.CreateAsync(It.IsAny <ProductCategoryDto>()), Times.Once);
        }
예제 #2
0
        public async Task <IActionResult> Create(CreateProductCategoryInput input)
        {
            var result = await _service.CreateAsync(input);

            return(new OperationActionResult(result));
        }