Inheritance: Peasy.Core.RuleBase
Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
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();
     rule.IsValid.ShouldBe(false);
     rule.ErrorMessage.ShouldNotBe(null);
 }