示例#1
0
    public IEnumerator LineDownTest()
    {
        // Use the Assert class to test conditions.
        // yield to skip a frame

        CommonInstall();
        var gameSettings         = GameSettingsInstaller.InstallFromResource("GameSettingsInstaller");
        TetrisGameController ctr = Container.InstantiatePrefabForComponent <TetrisGameController>(gameSettings.TetrisGameControllerPrefab);

        ctr.isUpdatingFallingPiece = false;

        TetrisPiece piece = null;

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateRotate());

        yield return(ctr.IterateMoveCol(-5));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateRotate());

        yield return(ctr.IterateMoveCol(-4));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateRotate());

        yield return(ctr.IterateMoveCol(-3));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateRotate());

        yield return(ctr.IterateMoveCol(2));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateRotate());

        yield return(ctr.IterateMoveCol(3));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateRotate());

        yield return(ctr.IterateMoveCol(4));

        yield return(ctr.IterateFall());

        Assert.AreEqual(
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "1110000111\n" +
            "1110000111\n" +
            "1110000111",
            ctr.GetBoardString(),
            "Clear not right"
            );
    }
示例#2
0
    public IEnumerator DifferentLineTest()
    {
        CommonInstall();
        var gameSettings         = GameSettingsInstaller.InstallFromResource("GameSettingsInstaller");
        TetrisGameController ctr = Container.InstantiatePrefabForComponent <TetrisGameController>(gameSettings.TetrisGameControllerPrefab);

        ctr.isUpdatingFallingPiece = false;

        TetrisPiece piece = null;

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateMoveCol(-4));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.T);
        yield return(ctr.IterateRotate(3));

        yield return(ctr.IterateMoveCol(1));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateMoveCol(3));

        yield return(ctr.IterateFall());


        piece = ctr.CreatePiece(TetrisPiece.PieceType.T);
        yield return(ctr.IterateMoveCol(-2));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.T);
        yield return(ctr.IterateRotate(1));

        yield return(ctr.IterateMoveCol(-4));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.T);
        yield return(ctr.IterateMoveCol(3));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateMoveCol(-2));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateMoveCol(2));

        yield return(ctr.IterateFall());

        piece = ctr.CreatePiece(TetrisPiece.PieceType.I);
        yield return(ctr.IterateRotate(1));

        yield return(ctr.IterateMoveCol(4));

        yield return(ctr.IterateFall());

        yield return(null);

        Assert.AreEqual(
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000000\n" +
            "0000000001\n" +
            "1110010101\n" +
            "1111011111",
            ctr.GetBoardString(),
            "Clear not right"
            );
    }