public void SetUp() { DbCommerce.GetInstance().StartTests(); Store store = new Store("Temp Store"); cart = new Cart(store, new MultiCart(1)); Workshop192.UserManagment.AllRegisteredUsers.GetInstance().CreateUser(); truePolicy = new PolicyLeafBannedUser("user"); falsePolicy = new PolicyLeafBannedUser(""); }
public PolicyComponent GetSellingPolicy() { if (this.sellingPolicy.Equals("")) { return(null); } PolicyComponent sellingPolicy = null; string[] str = this.sellingPolicy.Split('$'); foreach (string s in str) { sellingPolicy = CreatePolicy(s, sellingPolicy); } return(sellingPolicy); }
public PolicyComponent GetDiscountPolicy() { if (this.discountPolicy.Equals("")) { return(null); } PolicyComponent discountPolicy = null; string[] str = this.discountPolicy.Split('$'); foreach (string s in str) { discountPolicy = CreatePolicy(s, discountPolicy); } return(discountPolicy); }
private PolicyComponent CreatePolicy(string policy, PolicyComponent prePolicy) { PolicyComponent createdPolicy = null; string[] str = policy.Split('#'); switch (str[0]) { case "Ban": createdPolicy = new PolicyLeafBannedUser(str[3]); break; case "Max": createdPolicy = new PolicyLeafMaximumAmount(Int32.Parse(str[3]), Int32.Parse(str[4])); break; case "Min": createdPolicy = new PolicyLeafMinimumAmount(Int32.Parse(str[3]), Int32.Parse(str[4])); break; default: throw new ErrorMessageException("Syntax Error in given policy"); } if (prePolicy != null) { switch (str[1]) { case "AND": createdPolicy = new PolicyCompositeAnd(createdPolicy, prePolicy); break; case "OR": createdPolicy = new PolicyCompositeOr(createdPolicy, prePolicy); break; case "XOR": createdPolicy = new PolicyCompositeXor(createdPolicy, prePolicy); break; default: throw new ErrorMessageException("policy composite [" + str[1] + "] isnt supported"); } } return(createdPolicy); }
public PolicyCompositeXor(PolicyComponent left, PolicyComponent right) { this.left = left; this.right = right; }