Ejemplo n.º 1
0
        public void TestConstructorWhenPassNullShouldThrowException()
        {
            var            rng       = new RandomNumberGenerator();
            SmallPlayfield playfield = null;

            var memento = new Memento(playfield);
        }
        public void TestRenderPlayfieldShouldRenderAndFillGivenAsParameterField()
        {
            var playFieldToRender = new SmallPlayfield();

            var fakeConsoleRenderer = Mock.Create <IRenderer>();

            Mock.Arrange(() => fakeConsoleRenderer.RenderPlayfield(Arg.IsAny <IPlayfield>())).DoNothing();

            fakeConsoleRenderer.RenderPlayfield(playFieldToRender);
        }
        public void TestGetCellMethodShouldProperlyReturnSymbol()
        {
            var playfield = new SmallPlayfield();
            var rng = new RandomNumberGenerator();
            playfield.FillPlayfield(rng);

            playfield.SetCell(0, 0, "@");
            string actual = playfield.GetCell(0, 0);
            string expected = "@";

            Assert.AreEqual(expected, actual, "At position 0,0 the symbol should be @");
        }
        public void TestGetCellMethodShouldProperlyReturnSymbol()
        {
            var playfield = new SmallPlayfield();
            var rng       = new RandomNumberGenerator();

            playfield.FillPlayfield(rng);

            playfield.SetCell(0, 0, "@");
            string actual   = playfield.GetCell(0, 0);
            string expected = "@";

            Assert.AreEqual(expected, actual, "At position 0,0 the symbol should be @");
        }
        public void TestSetCellMethodUsingIPositionShouldProperlySetSymbolInGridAndGetMethodShouldReturnIt()
        {
            var playfield = new SmallPlayfield();
            IPosition position = new Position(0, 0);

            var rng = new RandomNumberGenerator();
            playfield.FillPlayfield(rng);

            playfield.SetCell(position.Row, position.Col, "@");
            string actual = playfield.GetCell(position.Row, position.Col);
            string expected = "@";

            Assert.AreEqual(expected, actual, "At position 0,0 the symbol should be @");
        }
        public void TestSetCellMethodUsingIPositionShouldProperlySetSymbolInGridAndGetMethodShouldReturnIt()
        {
            var       playfield = new SmallPlayfield();
            IPosition position  = new Position(0, 0);

            var rng = new RandomNumberGenerator();

            playfield.FillPlayfield(rng);

            playfield.SetCell(position.Row, position.Col, "@");
            string actual   = playfield.GetCell(position.Row, position.Col);
            string expected = "@";

            Assert.AreEqual(expected, actual, "At position 0,0 the symbol should be @");
        }
        public void TestConstructorShouldCopyCorrectPlayfield()
        {
            var rng = new RandomNumberGenerator();
            var playfield = new SmallPlayfield();
            playfield.FillPlayfield(rng);

            var memento = new Memento(playfield);
            bool areEqual = true;

            for (int row = 0; row < playfield.Size; row++)
            {
                for (int col = 0; col < playfield.Size; col++)
                {
                    if (playfield.GetCell(row, col) != memento.Grid[row, col])
                    {
                        areEqual = false;
                    }
                }
            }

            Assert.IsTrue(areEqual);
        }
Ejemplo n.º 8
0
        public void TestConstructorShouldCopyCorrectPlayfield()
        {
            var rng       = new RandomNumberGenerator();
            var playfield = new SmallPlayfield();

            playfield.FillPlayfield(rng);

            var  memento  = new Memento(playfield);
            bool areEqual = true;

            for (int row = 0; row < playfield.Size; row++)
            {
                for (int col = 0; col < playfield.Size; col++)
                {
                    if (playfield.GetCell(row, col) != memento.Grid[row, col])
                    {
                        areEqual = false;
                    }
                }
            }

            Assert.IsTrue(areEqual);
        }