示例#1
0
 def setUp(self):
     self.instruction = Instruction("Soy la instruccion 1", True)
     self.program = Program(self.instruction)
示例#2
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.")
示例#3
0
 def test_when_get_file_then_returns_file(self):
     program = Program()
     program.set_name('binfile')
     self.fs.put_file('/binfile', program)
     file = self.fs.get_file('/binfile')
     self.assertEqual(program,file)
示例#4
0
instruction10 = Instruction("hello, i am the instruction number ten.", "CPU")
instruction11 = Instruction("hello, i am the instruction number eleven.", "CPU")
instruction12 = Instruction("hello, i am the instruction number twelve.", "CPU")
instruction13 = Instruction("hello, i am the instruction number thirteen.", "CPU")
instruction14 = Instruction("hello, i am the instruction number fourteen.", "CPU")
instruction15 = Instruction("hello, i am the instruction number fifteen.", "CPU")
instruction16 = Instruction("hello, i am the instruction number sixteen.", "CPU")
instruction17 = Instruction("hello, i am the instruction number seventeen.", "CPU")
instruction18 = Instruction("hello, i am the instruction number eighteen.", "CPU")
instruction19 = Instruction("hello, i am the instruction number nineteen.", "CPU")
instruction20 = Instruction("hello, i am the instruction number twenty.", "CPU")
io_instruction = Instruction("hello, i am IO instruction of the program Tomboy.", "IO", IO_Keyboard, "INPUT")
io_instruction_output = Instruction("hello, i am IO instruction, i am show you a input.", "IO", IO_Keyboard, "OUTPUT")


fifa = Program()
fifa.set_name("fifa")
fifa.append_instruction(instruction1)
fifa.append_instruction(instruction2)
fifa.append_instruction(instruction3)
fifa.append_instruction(instruction4)
fifa.append_instruction(instruction5)
fifa.append_instruction(instruction6)
fifa.append_instruction(instruction7)
fifa.append_instruction(instruction8)
fifa.append_instruction(instruction9)
fifa.append_instruction(instruction10)


office = Program()
office.set_name("office")
示例#5
0
 def test_when_put_file_binfile_then_binfile_exists(self):
     program = Program()
     program.set_name('binfile')
     self.fs.put_file('/binfile', program)
     self.assertTrue(self.fs.file_exists('/binfile'))