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