def testGivenEmptyEquationWhenAddTermThenTermIsAddedInBothSides(self): equation = EquationBuilder().build() term = VariableBuilder().build() inverse_term = term.clon() inverse_term.multiply(-1.0) equation.add(term) self.assertEqual(equation.get_name_set(), {term.name}) equation.add_side(Side.left, inverse_term) equation.simplify_variable(Side.left, term.name) self.assertEqual(equation.get_value_constant(Side.left), 0.0) self.assertEqual(equation.get_name_set(), {term.name}) equation.add_side(Side.right, inverse_term) equation.simplify_variable(Side.right, term.name) self.assertEqual(equation.get_value_constant(Side.right), 0.0) self.assertEqual(equation.get_name_set(), set())
def testGivenEmptyEquationWhenAddConstantThenItIsAddedInBothSides(self): equation = EquationBuilder().build() term = ConstantBuilder().build() equation.add(term) self.assertEqual(equation.get_value_constant(Side.left), term.value) self.assertEqual(equation.get_value_constant(Side.right), term.value)