public async void CreateProductCategoryAsync_EntityWithExistedCode_CustomExceptionThrows([Frozen] Mock <IProductCatalogueContext> context, Bll.ProductCategoryService service, IFixture fixture)
        {
            Configure(context, fixture);
            var updateProductCategoryRequest = fixture.Create <Bll.UpdateProductCategoryRequest>();

            updateProductCategoryRequest.Code = _productCategory[0].Code;

            await Assert.ThrowsAsync <RequestedResourceHasConflictException>(() => service.CreateCategoryAsync(updateProductCategoryRequest));
        }
        public async void UpdateProductCategoryAsync_ValidEntity_SuccessfullHiveEdition([Frozen] Mock <IProductCatalogueContext> context, Bll.ProductCategoryService service, IFixture fixture)
        {
            Configure(context, fixture);
            var updateProductCategoryRequest = fixture.Create <Bll.UpdateProductCategoryRequest>();
            int id = _productCategory[0].Id;

            var result = await service.UpdateCategoryAsync(id, updateProductCategoryRequest);

            result.Id.Should().Be(id);
            result.Code.Should().Be(updateProductCategoryRequest.Code);
            result.Name.Should().Be(updateProductCategoryRequest.Name);
        }
        public async void GetProductCategoryAsync_OneValidEntity_ValidEntityReturns([Frozen] Mock <IProductCatalogueContext> context, Bll.ProductCategoryService service, IFixture fixture)
        {
            Configure(context, fixture);

            var result = await service.GetCategoryAsync(_productCategory[0].Id);

            result.Code.Should().Be(_productCategory[0].Code);
            result.Name.Should().Be(_productCategory[0].Name);
        }
        public async void GetProductCategoryAsync_NotExistedEntityIdentifier_CustomExceptionThrows([Frozen] Mock <IProductCatalogueContext> context, Bll.ProductCategoryService service, IFixture fixture)
        {
            Configure(context, fixture);
            var id = 0;

            await Assert.ThrowsAsync <RequestedResourceNotFoundException>(() => service.GetCategoryAsync(id));
        }
        public async void GetProductCategoriesAsync_TenEntities_SeccessfulResult([Frozen] Mock <IProductCatalogueContext> context, Bll.ProductCategoryService service, IFixture fixture)
        {
            Configure(context, fixture);
            var product = fixture.CreateMany <CatalogueProduct>(10).ToList();

            context.Setup(c => c.Products).ReturnsAsyncEntitySet(product);

            var result = await service.GetCategoriesAsync(0, _productCategory.Count);

            result.Should().HaveCount(_productCategory.Count);
        }
        public async void SetStatusAsync_EntityHasFlagIsDeletedFalseSetTrue_SuccsessfulChange([Frozen] Mock <IProductCatalogueContext> context, Bll.ProductCategoryService service, IFixture fixture)
        {
            Configure(context, fixture);
            _productCategory[0].IsDeleted = false;

            await service.SetStatusAsync(_productCategory[0].Id, true);

            _productCategory[0].IsDeleted.Should().Be(true);
        }
        public async void DeleteProductCategoryAsync_ExistedIdentifierFlagIsDeletedFalse_CustomExceptionThrows([Frozen] Mock <IProductCatalogueContext> context, Bll.ProductCategoryService service, IFixture fixture)
        {
            Configure(context, fixture);
            var id = _productCategory[0].Id;

            _productCategory[0].IsDeleted = false;

            await Assert.ThrowsAsync <RequestedResourceHasConflictException>(() => service.DeleteCategoryAsync(id));
        }
        public async void DeleteCategoryAsync_ExistedIdentifierFlagIsDeletedTrue_SuccessfulDeleting([Frozen] Mock <IProductCatalogueContext> context, Bll.ProductCategoryService service, IFixture fixture)
        {
            Configure(context, fixture);
            var id = _productCategory[0].Id;

            _productCategory[0].IsDeleted = true;

            await service.DeleteCategoryAsync(id);

            await Assert.ThrowsAsync <RequestedResourceNotFoundException>(() => service.GetCategoryAsync(id));
        }
        public async void UpdateProductCategoryAsync_NotExistedEntityIdentifier_CustomExceptionThrows([Frozen] Mock <IProductCatalogueContext> context, Bll.ProductCategoryService service, IFixture fixture)
        {
            Configure(context, fixture);
            var updateProductCategoryRequest = fixture.Create <Bll.UpdateProductCategoryRequest>();
            int id = 0;

            await Assert.ThrowsAsync <RequestedResourceNotFoundException>(() => service.UpdateCategoryAsync(id, updateProductCategoryRequest));
        }