public SetRuleOptions(Sign initialSign) { Rule1 = new SetRule(initialSign.M, null); Rule2 = new SetRule(null, initialSign.N); }
public SetRuleOptions AttemptIncludeSign(Sign sign) { if (Considers2Rules) { var rule1Compat = Rule1.IsCompatibleWith(sign); var rule1Support = Rule1.ActivelySupports(sign); var rule2Compat = Rule2.IsCompatibleWith(sign); var rule2Support = Rule2.ActivelySupports(sign); if (!Rule1.IsFixed) { if (rule1Support && rule2Support) { return(this); } if (rule1Support) { return(new SetRuleOptions(Rule1)); } if (rule2Support) { return(new SetRuleOptions(Rule2)); } return(new SetRuleOptions( new SetRule(Rule1.Left, sign.N), new SetRule(sign.M, Rule2.Right) )); } else { if (rule1Compat && rule2Compat) { return(this); } if (rule1Compat) { return(new SetRuleOptions(Rule1)); } if (rule2Compat) { return(new SetRuleOptions(Rule2)); } return(BrokenRule); } } else { var rule1Compat = Rule1.IsCompatibleWith(sign); var rule1Support = Rule1.ActivelySupports(sign); if (!rule1Compat) { return(BrokenRule); } if (rule1Support) { return(this); } else { return(new SetRuleOptions(Rule1.ExpandToSupport(sign))); } } }
public void SetRule() { int x = 1; int y = 2; int a = 3; int b = 4; var xaRule = new CaseSolver.SetRule(x, a); var x_blank_Rule = new CaseSolver.SetRule(x, null); var blank_a_Rule = new CaseSolver.SetRule(null, a); var blank_blank_Rule = new CaseSolver.SetRule(); var xaSign = new Sign(1, x, a); var xbSign = new Sign(1, x, b); var yaSign = new Sign(1, y, a); var ybSign = new Sign(1, y, b); xaRule.IsCompatibleWith(xaSign).Should().BeTrue(); xaRule.IsCompatibleWith(xbSign).Should().BeTrue(); xaRule.IsCompatibleWith(yaSign).Should().BeTrue(); xaRule.IsCompatibleWith(ybSign).Should().BeFalse(); xaRule.ActivelySupports(xaSign).Should().BeTrue(); xaRule.ActivelySupports(xbSign).Should().BeTrue(); xaRule.ActivelySupports(yaSign).Should().BeTrue(); xaRule.ActivelySupports(ybSign).Should().BeFalse(); x_blank_Rule.IsCompatibleWith(xaSign).Should().BeTrue(); x_blank_Rule.IsCompatibleWith(xbSign).Should().BeTrue(); x_blank_Rule.IsCompatibleWith(yaSign).Should().BeTrue(); x_blank_Rule.IsCompatibleWith(ybSign).Should().BeTrue(); x_blank_Rule.ActivelySupports(xaSign).Should().BeTrue(); x_blank_Rule.ActivelySupports(xbSign).Should().BeTrue(); x_blank_Rule.ActivelySupports(yaSign).Should().BeFalse(); x_blank_Rule.ActivelySupports(ybSign).Should().BeFalse(); blank_a_Rule.IsCompatibleWith(xaSign).Should().BeTrue(); blank_a_Rule.IsCompatibleWith(xbSign).Should().BeTrue(); blank_a_Rule.IsCompatibleWith(yaSign).Should().BeTrue(); blank_a_Rule.IsCompatibleWith(ybSign).Should().BeTrue(); blank_a_Rule.ActivelySupports(xaSign).Should().BeTrue(); blank_a_Rule.ActivelySupports(xbSign).Should().BeFalse(); blank_a_Rule.ActivelySupports(yaSign).Should().BeTrue(); blank_a_Rule.ActivelySupports(ybSign).Should().BeFalse(); blank_blank_Rule.IsCompatibleWith(xaSign).Should().BeTrue(); blank_blank_Rule.IsCompatibleWith(xbSign).Should().BeTrue(); blank_blank_Rule.IsCompatibleWith(yaSign).Should().BeTrue(); blank_blank_Rule.IsCompatibleWith(ybSign).Should().BeTrue(); blank_blank_Rule.ActivelySupports(xaSign).Should().BeFalse(); blank_blank_Rule.ActivelySupports(xbSign).Should().BeFalse(); blank_blank_Rule.ActivelySupports(yaSign).Should().BeFalse(); blank_blank_Rule.ActivelySupports(ybSign).Should().BeFalse(); }