示例#1
0
    public void TestApplyDesign()
    {
        Blueprint composite = new Blueprint(4, 5, 4);

        Blueprint long_block = new Blueprint(4, 1, 1);

        long_block.AddBlock(new Discrete3DCoord(0, 0, 0), 1);
        long_block.AddBlock(new Discrete3DCoord(1, 0, 0), 1);
        long_block.AddBlock(new Discrete3DCoord(2, 0, 0), 1);
        long_block.AddBlock(new Discrete3DCoord(3, 0, 0), 1);

        Blueprint tall_block = new Blueprint(2, 3, 1);

        tall_block.AddBlock(new Discrete3DCoord(0, 0, 0), 1);
        tall_block.AddBlock(new Discrete3DCoord(0, 1, 0), 1);
        tall_block.AddBlock(new Discrete3DCoord(0, 2, 0), 1);

        Blueprint really_really_long_block = new Blueprint(10, 1, 1);

        really_really_long_block.AddBlock(new Discrete3DCoord(0, 0, 0), 1);
        really_really_long_block.AddBlock(new Discrete3DCoord(1, 0, 0), 1);
        really_really_long_block.AddBlock(new Discrete3DCoord(2, 0, 0), 1);
        really_really_long_block.AddBlock(new Discrete3DCoord(3, 0, 0), 1);
        really_really_long_block.AddBlock(new Discrete3DCoord(4, 0, 0), 1);
        really_really_long_block.AddBlock(new Discrete3DCoord(5, 0, 0), 1);
        really_really_long_block.AddBlock(new Discrete3DCoord(6, 0, 0), 1);
        really_really_long_block.AddBlock(new Discrete3DCoord(7, 0, 0), 1);
        really_really_long_block.AddBlock(new Discrete3DCoord(8, 0, 0), 1);
        really_really_long_block.AddBlock(new Discrete3DCoord(9, 0, 0), 1);

        composite.ApplyDesign(long_block, 0, 0, 0);

        List <int> unique_ids = new List <int>();

        unique_ids.Add(composite.GetBlocks()[0, 0, 0]);
        CollectionAssert.AllItemsAreUnique(unique_ids);
        CollectionAssert.DoesNotContain(unique_ids, 0);

        composite.ApplyDesign(tall_block, 0, 1, 0);
        unique_ids.Add(composite.GetBlocks()[0, 1, 0]);
        CollectionAssert.AllItemsAreUnique(unique_ids);
        CollectionAssert.DoesNotContain(unique_ids, 0);

        composite.ApplyDesign(tall_block, 3, 1, 0);
        unique_ids.Add(composite.GetBlocks()[3, 1, 0]);
        CollectionAssert.AllItemsAreUnique(unique_ids);
        CollectionAssert.DoesNotContain(unique_ids, 0);

        composite.ApplyDesign(really_really_long_block, 0, 3, 0);
        unique_ids.Add(composite.GetBlocks()[0, 3, 0]);
        CollectionAssert.AllItemsAreUnique(unique_ids);
        CollectionAssert.DoesNotContain(unique_ids, 0);

        Assert.AreEqual(composite.GetBlocks()[0, 3, 0], composite.GetBlocks()[3, 3, 0]);
    }