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 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); bool isValid = rule.Validate().IsValid; Assert.IsTrue(isValid, "Rule validation result should be TRUE!"); Assert.IsNull(rule.ErrorMessage, "Rule Error message should be NULL!"); }