상속: Peasy.Core.RuleBase
예제 #1
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);
 }
예제 #2
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);
 }
예제 #3
0
 public async Task Is_valid_when_no_associated_orders_exist_async()
 {
     var productID = 1;
     var orderDataProxy = new Mock<IOrderDataProxy>();
     orderDataProxy.Setup(p => p.GetByProductAsync(productID))
                   .Returns(Task.FromResult(Enumerable.Empty<Order>()));
     var rule = new CanDeleteProductRule(productID, orderDataProxy.Object);
     await rule.ValidateAsync();
     rule.IsValid.ShouldBe(true);
     rule.ErrorMessage.ShouldBe(null);
 }
예제 #4
0
 public async Task Is_invalid_when_associated_orders_exist_async()
 {
     var productID = 1;
     var orderDataProxy = new Mock<IOrderDataProxy>();
     orderDataProxy.Setup(p => p.GetByProductAsync(productID))
                   .Returns(Task.FromResult(Enumerable.OfType<Order>(new[] { new Order() })));
     var orderService = new OrderService(orderDataProxy.Object, Mock.Of<IOrderItemService>(), Mock.Of<ITransactionContext>());
     var rule = new CanDeleteProductRule(productID, orderService);
     await rule.ValidateAsync();
     rule.IsValid.ShouldBe(false);
     rule.ErrorMessage.ShouldNotBe(null);
 }