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