コード例 #1
0
 def test_a_single_block_of_parallel_platform_moves_correctly_after_hitting_the_wall(self):
     platform = ParallelPlatformer(positions=[(1, 1)], directions=[(-1, 0)])
     platform.move_blocks()
     self.assertEqual(1, len(platform.get_block_positions()))
     self.assertTrue(platform.block_position_exists((2, 1)))
     self.assertListEqual([(2, 1)], platform.get_block_positions())
     self.assertListEqual([(1, 0)], platform.get_block_directions())
コード例 #2
0
 def test_a_single_block_moves_one_iteration_successfully(self):
     platform = ParallelPlatformer(positions=[(2, 1)], directions=[(-1, 0)])
     platform.move_blocks()
     self.assertEqual(1, len(platform.get_block_positions()))
     self.assertTrue(platform.block_position_exists((1, 1)))
     self.assertListEqual([(1, 1)], platform.get_block_positions())
     self.assertListEqual([(-1, 0)], platform.get_block_directions())
コード例 #3
0
 def test_two_blocks_move_two_iterations_successfully(self):
     platform = ParallelPlatformer(positions=[(3, 1), (3, 2)], directions=[(-1, 0), (1, 0)])
     for i in range(2):
         platform.move_blocks()
     self.assertEqual(2, len(platform.get_block_positions()))
     self.assertTrue(platform.block_position_exists((1, 1)))
     self.assertTrue(platform.block_position_exists((5, 2)))
     self.assertListEqual([(1, 1), (5, 2)], platform.get_block_positions())
     self.assertListEqual([(-1, 0), (1, 0)], platform.get_block_directions())
コード例 #4
0
 def test_platform_with_custom_positions_and_directions(self):
     result = ParallelPlatformer(number_blocks=10, positions=[(2, 3), (3, 4)], directions=[(-1, 0), (1, 0)])
     self.assertEqual(2, len(result.get_block_positions()))
     self.assertTrue(result.block_position_exists((2, 3)))
     self.assertListEqual([(2, 3), (3, 4)], result.get_block_positions())
     self.assertListEqual([(-1, 0), (1, 0)], result.get_block_directions())
コード例 #5
0
 def test_basic_custom_platform(self):
     result = ParallelPlatformer(number_blocks=4, plane=Plane(z=[0, 11]))
     self.assertEqual(4, len(result.get_block_positions()))
     self.assertEqual(len(result.get_block_positions()), len(list(set(result.get_block_positions()))))
     self.assertEqual(len(result.get_block_positions()), len(result.get_block_directions()))
コード例 #6
0
 def test_default_platform(self):
     result = ParallelPlatformer()
     self.assertEqual(8, len(result.get_block_positions()))
     self.assertEqual(len(result.get_block_positions()), len(list(set(result.get_block_positions()))))
     self.assertEqual(len(result.get_block_positions()), len(result.get_block_directions()))