public void ExecuteRules_ZeroAmount_HasRuleViolation() { var ruleEngine = new RuleEngine<SelfPayment>(new SelfPaymentRuleCollection()); var selfPayment = new SelfPayment( new Mock<Patient>().Object, new Mock<Staff>().Object, new Money(new Currency("en-US"), 0), new PaymentMethod(), DateTime.Now); var results = ruleEngine.ExecuteAllRules(selfPayment); Assert.IsTrue(results.HasRuleViolation); }
/// <summary> /// Creates the self payment. /// </summary> /// <param name="patient">The patient.</param> /// <param name="staff">The staff.</param> /// <param name="money">The money.</param> /// <param name="paymentMethod">The payment method.</param> /// <param name="collectedDate">The collected date.</param> /// <returns>A Self Payment.</returns> public SelfPayment CreateSelfPayment(Patient patient, Staff staff, Money money, PaymentMethod paymentMethod, DateTime?collectedDate) { var selfPayment = new SelfPayment(patient, staff, money, paymentMethod, collectedDate); SelfPayment createdSelfPayment = null; DomainRuleEngine.CreateRuleEngine(selfPayment, "CreateSelfPaymentRuleSet") .Execute(() => { createdSelfPayment = selfPayment; _selfPaymentRepository.MakePersistent(createdSelfPayment); }); return(createdSelfPayment); }
/// <summary> /// Creates the self payment. /// </summary> /// <param name="patient">The patient.</param> /// <param name="staff">The staff.</param> /// <param name="money">The money.</param> /// <param name="paymentMethod">The payment method.</param> /// <param name="collectedDate">The collected date.</param> /// <returns>A Self Payment.</returns> public SelfPayment CreateSelfPayment( Patient patient, Staff staff, Money money, PaymentMethod paymentMethod, DateTime? collectedDate ) { var selfPayment = new SelfPayment ( patient, staff, money, paymentMethod, collectedDate ); SelfPayment createdSelfPayment = null; DomainRuleEngine.CreateRuleEngine ( selfPayment, "CreateSelfPaymentRuleSet" ) .Execute ( () => { createdSelfPayment = selfPayment; _selfPaymentRepository.MakePersistent(createdSelfPayment); }); return createdSelfPayment; }
/// <summary> /// Destroys the self payment. /// </summary> /// <param name="selfPayment">The self payment.</param> public void DestroySelfPayment(SelfPayment selfPayment) { _selfPaymentRepository.MakeTransient(selfPayment); }
/// <summary> /// Destroys the self payment. /// </summary> /// <param name="selfPayment">The self payment.</param> public void DestroySelfPayment( SelfPayment selfPayment ) { _selfPaymentRepository.MakeTransient ( selfPayment ); }