public void NotExpressionReturnsOppositeValueForVariable()
 {
     {
         // !a => true for a = false
         IExpression ne = new NotExpression(new VariableTerminalExpression("a"));
         Assert.AreEqual(true, ne.Interpret(new Context(new Dictionary <string, bool>()
         {
             { "a", false }, { "b", true }
         })));
     }
     {
         // !b => false for b = true
         IExpression ne = new NotExpression(new VariableTerminalExpression("b"));
         Assert.AreEqual(false, ne.Interpret(new Context(new Dictionary <string, bool>()
         {
             { "a", false }, { "b", true }
         })));
     }
 }
 public void XorExpressionReturnsFalseWhenBothOperandAreTrue()
 {
     {
         IExpression left  = new ConstantTerminalExpression(true);
         IExpression right = new ConstantTerminalExpression(true);
         IExpression xor   = new XorExpression(left, right);
         Assert.AreEqual(false, xor.Interpret(new Context()));
     }
     {
         IExpression left  = new VariableTerminalExpression("a");
         IExpression right = new VariableTerminalExpression("b");
         IExpression xor   = new XorExpression(left, right);
         Assert.AreEqual(false, xor.Interpret(new Context(new Dictionary <string, bool>()
         {
             { "a", true }, { "b", true }
         })));
     }
     {
         // true ^ a => false for a = true
         IExpression left  = new ConstantTerminalExpression(true);
         IExpression right = new VariableTerminalExpression("a");
         IExpression xor   = new XorExpression(left, right);
         Assert.AreEqual(false, xor.Interpret(new Context(new Dictionary <string, bool>()
         {
             { "a", true }
         })));
     }
     {
         // a ^ !b => false for a = false and b = true
         IExpression left  = new NotExpression(new VariableTerminalExpression("a"));
         IExpression right = new VariableTerminalExpression("b");
         IExpression xor   = new XorExpression(left, right);
         Assert.AreEqual(false, xor.Interpret(new Context(new Dictionary <string, bool>()
         {
             { "a", false }, { "b", true }
         })));
     }
 }
 public void AndExpressionReturnsFalseWhenBothOperandAreFalse()
 {
     {
         IExpression left  = new ConstantTerminalExpression(false);
         IExpression right = new ConstantTerminalExpression(false);
         IExpression and   = new AndExpression(left, right);
         Assert.AreEqual(false, and.Interpret(new Context()));
     }
     {
         IExpression left  = new VariableTerminalExpression("a");
         IExpression right = new VariableTerminalExpression("b");
         IExpression and   = new AndExpression(left, right);
         Assert.AreEqual(false, and.Interpret(new Context(new Dictionary <string, bool>()
         {
             { "a", false }, { "b", false }
         })));
     }
     {
         // false && a => false for a = false
         IExpression left  = new ConstantTerminalExpression(false);
         IExpression right = new VariableTerminalExpression("a");
         IExpression and   = new AndExpression(left, right);
         Assert.AreEqual(false, and.Interpret(new Context(new Dictionary <string, bool>()
         {
             { "a", false }
         })));
     }
     {
         // a && !b => false for a = false and b = true
         IExpression left  = new VariableTerminalExpression("a");
         IExpression right = new NotExpression(new VariableTerminalExpression("b"));
         IExpression and   = new AndExpression(left, right);
         Assert.AreEqual(false, and.Interpret(new Context(new Dictionary <string, bool>()
         {
             { "a", false }, { "b", true }
         })));
     }
 }