示例#1
0
class Test(unittest.TestCase):
    def setUp(self):
        self.instruction = Instruction("Soy la instruccion 1", True)
        self.program = Program(self.instruction)

    def test_program_length(self):
        self.assertEqual(self.program.length(), 1,
                         "The numbers are not equals.")

    def test_program_length_fail(self):
        self.assertNotEqual(self.program.length(), 2,
                            "The numbers are equals.")

    def test_append_Instruction_and_inrementate_the_instructions_length(self):
        self.program.append_instruction(
            Instruction("Soy la instruccion 2", True))
        self.assertEqual(self.program.length(), 2,
                         "The numbers are not equals.")

    def test_append_Instruction_and_inrementate_the_instructions_length_fail(
            self):
        self.program.append_instruction(
            Instruction("Soy la instruccion 2", True))
        self.assertNotEqual(self.program.length(), 1,
                            "The numbers are equals.")

    def test_get_a_specific_instruction(self):
        self.assertEqual(
            self.program.get_a_instruction(0), self.instruction,
            "The instructions are not equals.")

    def test_get_a_specific_instruction_fail(self):
        self.assertNotEqual(
            self.program.get_a_instruction(0),
            Instruction("Soy otra instruccion", True),
            "The instructions are equals.")

    def get_last_instruction(self):
        self.assertEquals(self.program.get_last_instruction(),
                          self.instruction, "The numbers are not equals.")

    def get_last_instruction_fail(self):
        self.assertEquals(self.program.get_last_instruction(),
                          Instruction("A instruction foo", True),
                          "The numbers are not equals.")

    def test_append_a_Instruction(self):
        self.newInstruction = Instruction("a new instruction.", True)
        self.program.append_instruction(self.newInstruction)
        self.assertEquals(self.program.get_last_instruction(),
                          self.newInstruction,
                          "The instructions are not equals.")

    def test_append_a_Instruction_fail(self):
        self.newInstruction = Instruction("a new instruction.", True)
        self.program.append_instruction(self.newInstruction)
        self.assertNotEquals(self.program.get_last_instruction(),
                             Instruction("a another instruction.", True),
                             "The instructions are equals.")