예제 #1
0
        public void TestStepRight()
        {
            var glass = new Glass();
            Assert.IsTrue(glass.AddFigure(new FigureO()));

            glass.StepRight();

            var arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));

            glass.StepRight();
            glass.StepRight();
            glass.StepRight();
            glass.StepRight();
            glass.StepRight();
            glass.StepRight();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            glass = Glass.createTestGlass ( arr );

            Assert.IsTrue(glass.AddFigure(new FigureJ()));

            glass.StepRight();
            glass.StepRight();
            glass.StepRight();
            glass.StepRight();
            glass.StepRight();
            glass.StepRight();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
        }
예제 #2
0
        public void TestStepDown()
        {
            var glass = new Glass();
            Assert.IsTrue(glass.AddFigure(new FigureI()));

            glass.StepDown();

            var arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));

            for(int i = 0; i < 20; ++i)
                glass.StepDown();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse ( glass.IsRunning() );

            Assert.IsTrue(glass.AddFigure(new FigureS()));
            Assert.IsTrue(glass.IsRunning());

            for(int i = 0; i < 20; ++i)
                glass.StepDown();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());
        }
예제 #3
0
        public void TestAddFigure()
        {
            var glass = new Glass();
            var arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue ( glass.AddFigure ( new FigureI() ) );
            Assert.IsTrue ( glass.compareFields ( arr ));
            Assert.IsTrue ( glass.IsRunning() );
            Assert.IsFalse( glass.IsFull());

            glass = new Glass();
            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.AddFigure(new FigureT()));
            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsTrue(glass.IsRunning());
            Assert.IsFalse(glass.IsFull());

            glass = new Glass();
            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.AddFigure(new FigureL()));
            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsTrue(glass.IsRunning());
            Assert.IsFalse(glass.IsFull());

            glass = new Glass();
            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.AddFigure(new FigureO()));
            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsTrue(glass.IsRunning());
            Assert.IsFalse(glass.IsFull());

            glass = new Glass();
            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.AddFigure(new FigureS()));
            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsTrue(glass.IsRunning());
            Assert.IsFalse(glass.IsFull());
            // добавить вторую фигуру подряд
            Assert.IsFalse(glass.AddFigure(new FigureS()));
            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsTrue(glass.IsRunning());
            Assert.IsFalse(glass.IsFull());

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };
            glass = Glass.createTestGlass(arr);

            Assert.IsFalse(glass.AddFigure(new FigureS()));
            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());
            Assert.IsTrue(glass.IsFull());
        }
예제 #4
0
        public void TestRotate()
        {
            var glass = new Glass();
            Assert.IsTrue(glass.AddFigure(new FigureL()));

            glass.Rotate();

            var arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));

            glass.Rotate();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));

            glass = new Glass();
            Assert.IsTrue(glass.AddFigure(new FigureS()));

            glass.Rotate();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));

            glass.Rotate();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            glass = Glass.createTestGlass(arr);

            Assert.IsTrue(glass.AddFigure(new FigureT()));

            glass.Rotate();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
        }
예제 #5
0
        public void TestFallDown()
        {
            var glass = new Glass();

            Assert.IsTrue(glass.AddFigure(new FigureZ()));

            glass.FallDown();

            var arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());

            Assert.IsTrue(glass.AddFigure(new FigureT()));

            glass.FallDown();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());

            Assert.IsTrue(glass.AddFigure(new FigureS()));

            glass.FallDown();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());

            Assert.IsTrue(glass.AddFigure(new FigureO()));

            glass.FallDown();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());

            Assert.IsTrue(glass.AddFigure(new FigureL()));

            glass.FallDown();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,1,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());

            Assert.IsTrue(glass.AddFigure(new FigureJ()));

            glass.FallDown();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());

            Assert.IsTrue(glass.AddFigure(new FigureI()));

            glass.FallDown();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());

            Assert.IsFalse(glass.AddFigure(new FigureI()));

            glass.FallDown();

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue(glass.compareFields(arr));
            Assert.IsFalse(glass.IsRunning());
            Assert.IsTrue(glass.IsFull());
        }
예제 #6
0
        public void TestEatRows()
        {
            var arr = new[]{
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,1},
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,1,0,1},
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,0,1},
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,1,0,1,1},
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,1},
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1},
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,0,1,1},
                                    new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,0,1}
                                };

            var glass = Glass.createTestGlass ( arr );

            Assert.AreEqual ( 5, glass.EatRows() );

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}
                                };

            Assert.IsTrue ( glass.compareFields ( arr ) );

            glass = new Glass();
            int score = 0;

            Assert.IsTrue( glass.AddFigure(new FigureI()) );
            glass.Rotate();
            for (int i = 0; i < 10; ++i)
                glass.StepRight();
            glass.FallDown();
            score += glass.EatRows();

            Assert.IsTrue ( glass.AddFigure(new FigureI()) );
            glass.Rotate();
            for(int i = 0; i < 10; ++i)
                glass.StepLeft();
            glass.FallDown();
            score += glass.EatRows();

            Assert.IsTrue ( glass.AddFigure(new FigureL()) );
            glass.FallDown();
            score += glass.EatRows();

            Assert.AreEqual ( 1, score );

            arr = new[]{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
                                };

            Assert.IsTrue ( glass.compareFields ( arr ) );
        }