public void RotateColumnCommand_CreatedCorrectly()
        {
            var expected = new RotateColumnCommand(1, 1);

            var mockViewer = new Mock <IPixelViewer>();

            var commandStrings = new[] { "rotate column x=1 by 1" };

            var commands = new PixelViewerCommandFactory().Create(() => commandStrings);

            Assert.Equal(1, commands.Count());
            Assert.Equal(expected, commands.First());
        }
예제 #2
0
        public void TestRotateColumnCommand()
        {
            bool[,] matrix = new bool[4, 3]
            {
                { false,
                  false,
                  true }, { false,
                            false,
                            false }, { false,
                                       false,
                                       false }, { false,
                                                  false,
                                                  false }
            };



            RotateColumnCommand cmd = new RotateColumnCommand("rotate column x=0 by 2");

            cmd.ApplyCommand(matrix);
            Assert.AreEqual(false, matrix[0, 0]);
            Assert.AreEqual(true, matrix[0, 1]);
            Assert.AreEqual(false, matrix[0, 2]);
        }
예제 #3
0
        public void Column_RotatesElements()
        {
            var expectedColumn = new[] { new Pixel(0, 0, false), new Pixel(0, 1, false), new Pixel(0, 2, true) };

            var viewer = new[]
            {
                new Pixel[0],
                new[] { new Pixel(0, 0, isOn: false), new Pixel(0, 1, isOn: true), new Pixel(0, 2, isOn: false) },
                new Pixel[0]
            };

            Pixel[] actual = null;

            var mockViewer = new Mock <IPixelViewer>();

            mockViewer.Setup(a => a.Columns).Returns(() => viewer);
            mockViewer.Setup(a => a.Update(It.IsAny <Pixel[]>())).Callback <Pixel[]>(pixels => actual = pixels);

            var sut = new RotateColumnCommand(1, 1);

            sut.Update(mockViewer.Object);

            Assert.True(expectedColumn.SequenceEqual(actual));
        }