Exemplo n.º 1
0
        public void Is_invalid_when_associated_orders_exist()
        {
            var productID      = 1;
            var orderDataProxy = new Mock <IOrderDataProxy>();

            orderDataProxy.Setup(p => p.GetByProduct(productID)).Returns(Enumerable.OfType <Order>(new[] { new Order() }));
            var rule = new CanDeleteProductRule(productID, orderDataProxy.Object);

            rule.Validate().IsValid.ShouldBe(false);
            rule.ErrorMessage.ShouldNotBe(null);
        }
Exemplo n.º 2
0
        public void Is_valid_when_no_associated_orders_exist()
        {
            var productID      = 1;
            var orderDataProxy = new Mock <IOrderDataProxy>();

            orderDataProxy.Setup(p => p.GetByProduct(productID)).Returns(Enumerable.Empty <Order>());
            var rule = new CanDeleteProductRule(productID, orderDataProxy.Object);

            rule.Validate().IsValid.ShouldBe(true);
            rule.ErrorMessage.ShouldBe(null);
        }