Beispiel #1
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());
        }
Beispiel #2
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());
        }