[TestMethod()] //Test score for zero complete line public void CalculateScoreForZeroLineTest() { int count = (int)_canvas.Width / (4 * _width) - 1; for (int i = 0; i < count; i++) { //Creaet figure "I" - four blocks next to each other, like xxxx Figure figure = new Figure(4, _canvas, _width, _width, _width); figure.SetLocation(i * figure.Width, (int)_canvas.Height - figure.Height); _score = MovementHelper.CalculateScore(figure, _canvas, _score, out _lines); Assert.IsTrue(_lines == 0); Assert.IsTrue(_score == _lines * MovementHelper.DefaultUnits); } }
[TestMethod()] //Test score for two complete lines public void CalculateScoreForTwoLinesTest() { int count = (int)_canvas.Width / (2 * _width); for (int i = 0; i < count; i++) { //Creaet figure "O" - two blocks boven other two like square xx // xx Figure figure = new Figure(5, _canvas, _width, _width, _width); figure.SetLocation(i * figure.Width, (int)_canvas.Height - figure.Height); _score = MovementHelper.CalculateScore(figure, _canvas, _score, out _lines); } Assert.IsTrue(_lines == 2); Assert.IsTrue(_score == _lines * MovementHelper.DefaultUnits); }
[TestMethod()] //Test score for four complete lines public void CalculateScoreFourLinesTest() { int count = (int)_canvas.Width / (2 * _width); //Create figures "O" to fill the canvas with 4 rows for (int i = 0; i < count; i++) { Figure figure = new Figure(5, _canvas, _width, _width, _width); figure.SetLocation(i * figure.Width, (int)_canvas.Height - figure.Height); Figure figure2 = new Figure(5, _canvas, _width, _width, _width); figure2.SetLocation(i * figure2.Width, (int)_canvas.Height - figure2.Height - figure2.Height); _score = MovementHelper.CalculateScore(figure2, _canvas, _score, out _lines); } Assert.IsTrue(_lines == 4); Assert.IsTrue(_score == MovementHelper.TetrisUnits); }
[TestMethod()] //Test score for three complete lines public void CalculateScoreThreeLinesTest() { int count = (int)_canvas.Width / (4 * _width); for (int i = 0; i < count; i++) { //Creaet figures "I" and "O" to fill the canvas with 3 rows Figure figure1 = new Figure(4, _canvas, _width, _width, _width); figure1.SetLocation(i * figure1.Width, (int)_canvas.Height - figure1.Height); Figure figure2 = new Figure(5, _canvas, _width, _width, _width); figure2.SetLocation(i * figure1.Width, (int)_canvas.Height - figure1.Height - figure2.Height); Figure figure3 = new Figure(5, _canvas, _width, _width, _width); figure3.SetLocation(i * figure1.Width + figure2.Width, (int)_canvas.Height - figure1.Height - figure2.Height); _score = MovementHelper.CalculateScore(figure3, _canvas, _score, out _lines); } Assert.IsTrue(_lines == 3); Assert.IsTrue(_score == _lines * MovementHelper.DefaultUnits); }