Example #1
0
        public void WhenProductCategoryIsNullThenEditProductCategoryReturnNotSuccessfullResult()
        {
            var service = new ProductCategoryService(Mock.Of <IProductCategoryRepository>(), Mock.Of <IShopRepository>());

            var actionResult = service.EditProductCategory(null);

            actionResult.Status.Should().Be(ActionStatus.NotSuccessfull);
        }
Example #2
0
        public void WhenExceptionThrownThenReturnWithExceptionResult()
        {
            var productCategoryRepository = Mock.Of <IProductCategoryRepository>();

            Mock.Get(productCategoryRepository).Setup(r => r.GetProductCategory(It.IsAny <Guid>())).Throws <Exception>();
            var service = new ProductCategoryService(productCategoryRepository, Mock.Of <IShopRepository>());

            var actionResult = service.EditProductCategory(new ProductCategoryDto()
            {
                CategoryName = "Name"
            });

            actionResult.Status.Should().Be(ActionStatus.WithException);
        }
Example #3
0
        public void WhenProductCategoryWithDefinedNameAlreadyExistsThenEditProductCategoryReturnNotSuccessfull()
        {
            var productCategoryGuid       = Guid.Parse("{02C0CB50-DB9F-45EC-9C67-1D4550AA86EC}");
            var productCategory           = new ProductCategory("Name");
            var productCategoryRepository = Mock.Of <IProductCategoryRepository>(r => r.GetProductCategory(productCategoryGuid) == productCategory && r.GetProductCategoryByName(It.IsAny <Guid>(), "Name") == productCategory);
            var service = new ProductCategoryService(productCategoryRepository, Mock.Of <IShopRepository>());

            var actionResult = service.EditProductCategory(new ProductCategoryDto()
            {
                ProductCategoryGuid = productCategoryGuid, CategoryName = "Name"
            });

            actionResult.Status.Should().Be(ActionStatus.NotSuccessfull);
        }
Example #4
0
        public void WhenProductCategoryNotFoundThenEditProductCategoryReturnNotSuccessfullResult()
        {
            var productCategoryGuid       = Guid.Parse("{02C0CB50-DB9F-45EC-9C67-1D4550AA86EC}");
            var productCategoryRepository = Mock.Of <IProductCategoryRepository>();

            Mock.Get(productCategoryRepository).Setup(r => r.GetProductCategory(productCategoryGuid)).Returns((ProductCategory)null);
            var service = new ProductCategoryService(productCategoryRepository, Mock.Of <IShopRepository>());

            var actionResult = service.EditProductCategory(new ProductCategoryDto()
            {
                ProductCategoryGuid = productCategoryGuid
            });

            actionResult.Status.Should().Be(ActionStatus.NotSuccessfull);
        }
Example #5
0
        public void WhenProductCategoryIsUniqueThenEditProductCategoryReturnSuccessfull()
        {
            var productCategoryGuid       = Guid.Parse("{02C0CB50-DB9F-45EC-9C67-1D4550AA86EC}");
            var productCategory           = new ProductCategory("Name");
            var productCategoryRepository = Mock.Of <IProductCategoryRepository>(r => r.GetProductCategory(productCategoryGuid) == productCategory);

            Mock.Get(productCategoryRepository).Setup(r => r.GetProductCategoryByName(It.IsAny <Guid>(), "Name")).Returns((ProductCategory)null);
            var service = new ProductCategoryService(productCategoryRepository, Mock.Of <IShopRepository>());

            var actionResult = service.EditProductCategory(new ProductCategoryDto()
            {
                ProductCategoryGuid = productCategoryGuid, CategoryName = "Name"
            });

            actionResult.Should().Be(ServiceActionResult.Successfull);
        }