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()); }
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 ) ); }