public async Task Is_invalid_when_associated_products_exist_async()
        {
            var categoryID = 1;
            var proxyMock  = new Mock <IProductDataProxy>();

            proxyMock.Setup(proxy => proxy.GetByCategoryAsync(categoryID))
            .Returns(Task.FromResult((new[] { new Product() }).AsEnumerable <Product>()));
            var rule = new CanDeleteCategoryRule(categoryID, proxyMock.Object);
            await rule.ValidateAsync();

            rule.IsValid.ShouldBe(false);
            rule.ErrorMessage.ShouldNotBe(null);
        }
示例#2
0
        public async Task Is_invalid_when_associated_products_exist_async()
        {
            var categoryID = 1;
            var proxyMock  = new Mock <IProductDataProxy>();

            proxyMock.Setup(proxy => proxy.GetByCategoryAsync(categoryID)).Returns(Task.FromResult((new[] { new Product() }).AsEnumerable <Product>()));
            var rule = new CanDeleteCategoryRule(categoryID, proxyMock.Object);

            await rule.ValidateAsync();

            bool isValid = rule.IsValid;

            Assert.IsFalse(isValid, "Rule validation result should be TRUE!");
            Assert.IsNotNull(rule.ErrorMessage, "Rule Error message should be NULL!");
        }