public void AssignSimpleAddition() { var command = ParseCommand("assign a to 3 + 2"); Assert.IsTrue(command is VariableAssignmentCommand); VariableAssignmentCommand assignment = (VariableAssignmentCommand)command; Assert.IsTrue(assignment.variable is OperandVariable); OperandVariable variable = (OperandVariable)assignment.variable; Assert.AreEqual(OperandType.ADD, variable.operand); Assert.AreEqual(5f, CastNumber(variable.GetValue()).GetValue()); }
public void DivisionBeforeAddition() { var command = ParseCommand("assign a to 4 / 2 + 3"); Assert.IsTrue(command is VariableAssignmentCommand); VariableAssignmentCommand assignment = (VariableAssignmentCommand)command; Assert.IsTrue(assignment.variable is OperandVariable); OperandVariable addVariable = (OperandVariable)assignment.variable; Assert.AreEqual(5f, CastNumber(addVariable.GetValue()).GetNumericValue()); Assert.AreEqual(OperandType.ADD, addVariable.operand); Assert.IsTrue(addVariable.a is OperandVariable); Assert.IsTrue(addVariable.b is StaticVariable); OperandVariable multiplyVariable = (OperandVariable)addVariable.a; Assert.AreEqual(OperandType.DIVIDE, multiplyVariable.operand); }