def test_insert_floor_considering_direction_empty(self): behaviour = StandardElevator() destinations = [] behaviour.insert_floor_considering_direction(destinations, 2, behaviour.Direction.UP) expected = [2] self.assertEqual(destinations, expected)
def test_insert_floor_considering_direction_one_already_exists(self): behaviour = StandardElevator() destinations = [2, 4, 6, 8, 6, 4, 2] result = behaviour.insert_floor_considering_direction(destinations, 6, behaviour.Direction.DOWN) expected = [2, 4, 6, 8, 6, 4, 2] self.assertEqual(result, 4) self.assertEqual(destinations, expected)
def test_insert_floor_considering_direction_going_down_2(self): behaviour = StandardElevator() destinations = [8, 6, 4, 2, 4, 6, 8] result = behaviour.insert_floor_considering_direction(destinations, 5, behaviour.Direction.DOWN) expected = [8, 6, 5, 4, 2, 4, 6, 8] self.assertEqual(result, 2) self.assertEqual(destinations, expected)
def test_insert_floor_considering_direction_going_up(self): behaviour = StandardElevator() destinations = [2, 4, 6, 8, 6, 4, 2] result = behaviour.insert_floor_considering_direction(destinations, 3, behaviour.Direction.UP) expected = [2, 3, 4, 6, 8, 6, 4, 2] self.assertEqual(result, 1) self.assertEqual(destinations, expected)
def test_insert_floor_considering_direction_insert_duplicate_on_bottom(self): behaviour = StandardElevator() destinations = [2, 0, 2, 4] result = behaviour.insert_floor_considering_direction(destinations, 0, behaviour.Direction.UP) expected = [2, 0, 2, 4] self.assertEqual(result, 1) self.assertEqual(destinations, expected)
def test_insert_floor_considering_direction_insert_after_given_index_with_direction_change(self): behaviour = StandardElevator() destinations = [5, 0] result = behaviour.insert_floor_considering_direction(destinations, 10, behaviour.Direction.UP, after=1) expected = [5, 0, 10] self.assertEqual(result, 2) self.assertEqual(destinations, expected)
def test_insert_floor_considering_direction_insert_after_given_index(self): behaviour = StandardElevator() destinations = [2, 4, 6, 8] result = behaviour.insert_floor_considering_direction(destinations, 5, behaviour.Direction.UP, after=2) expected = [2, 4, 6, 8, 5] self.assertEqual(result, 4) self.assertEqual(destinations, expected)
def test_insert_floor_considering_direction_insert_after_start(self): behaviour = StandardElevator() destinations = [4] result = behaviour.insert_floor_considering_direction(destinations, 0, behaviour.Direction.UP) expected = [4, 0] self.assertEqual(result, 1) self.assertEqual(destinations, expected)
def test_insert_floor_considering_direction_bottom(self): behaviour = StandardElevator() destinations = [8, 6, 4, 2, 4] result = behaviour.insert_floor_considering_direction(destinations, 0, behaviour.Direction.DOWN) expected = [8, 6, 4, 2, 0, 4] self.assertEqual(result, 4) self.assertEqual(destinations, expected)
def test_insert_floor_considering_direction_no_suitable_place(self): behaviour = StandardElevator() destinations = [2, 4, 6, 8] result = behaviour.insert_floor_considering_direction(destinations, 5, behaviour.Direction.DOWN) expected = [2, 4, 6, 8, 5] self.assertEqual(result, 4) self.assertEqual(destinations, expected)