Ejemplo n.º 1
0
        public IFigure RandomFigure()
        {
            var     rnd                 = new Random();
            int     patternNumber       = rnd.Next(7);
            Pattern randomFigurePattern =
                new PatternLibrary().Patterns[patternNumber];
            var randomFigure = new Figure();

            randomFigure.RotationNumber = rnd.Next(4);
            randomFigure.Pattern        = randomFigurePattern;
            return(randomFigure);
        }
Ejemplo n.º 2
0
        public void PeekNextRotation_Should_Return_TetrisCup_With_Next_Rotation()
        {
            var figure = new Figure();

            figure.Pattern        = new PatternLibrary().Patterns[1];
            figure.RotationNumber = 3;
            var expectedCup = new PatternLibrary().Patterns[1].Rotations[0];
            var actualCup   = figure.PeekNextRotation();

            //сравнение чашек
            if ((actualCup.Width == expectedCup.Width) && (actualCup.Height == expectedCup.Height))
            {
                for (int x = 0; x < actualCup.Width; x++)
                {
                    for (int y = 0; y < actualCup.Height; y++)
                    {
                        if (actualCup.GetColorOfPoint(new Point(x, y)) != expectedCup.GetColorOfPoint(new Point(x, y)))
                        {
                            throw new Exception();
                        }
                    }
                }
            }
        }