Inheritance: Peasy.Core.RuleBase
 public void Is_invalid_when_associated_products_exist()
 {
     var categoryID = 1;
     var proxyMock = new Mock<IProductDataProxy>();
     proxyMock.Setup(proxy => proxy.GetByCategory(categoryID))
              .Returns(new[] { new Product() });
     var rule = new CanDeleteCategoryRule(categoryID, proxyMock.Object);
     rule.Validate().IsValid.ShouldBe(false);
     rule.ErrorMessage.ShouldNotBe(null);
 }
 public void Is_valid_when_no_associated_products_exist()
 {
     var categoryID = 1;
     var proxyMock = new Mock<IProductDataProxy>();
     proxyMock.Setup(proxy => proxy.GetByCategory(categoryID))
              .Returns(Enumerable.Empty<Product>());
     var rule = new CanDeleteCategoryRule(categoryID, proxyMock.Object);
     rule.Validate().IsValid.ShouldBe(true);
     rule.ErrorMessage.ShouldBe(null);
 }
 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);
 }