public void TestRotateRowCommand() { bool[,] matrix = new bool[4, 3] { { false, false, true }, { false, false, false }, { false, false, false }, { false, false, false } }; RotateRowCommand cmd = new RotateRowCommand("rotate row y=2 by 2"); cmd.ApplyCommand(matrix); Assert.AreEqual(false, matrix[0, 2]); Assert.AreEqual(false, matrix[1, 2]); Assert.AreEqual(true, matrix[2, 2]); Assert.AreEqual(false, matrix[3, 2]); }
public void RotateRowCommand_CreatedCorrectly() { var expected = new RotateRowCommand(0, 4); var mockViewer = new Mock <IPixelViewer>(); var commandStrings = new[] { "rotate row y=0 by 4" }; var commands = new PixelViewerCommandFactory().Create(() => commandStrings); Assert.Equal(1, commands.Count()); Assert.Equal(expected, commands.First()); }
public void Row_RotatesElements() { var expectedRow = new[] { new Pixel(0, 1, true), new Pixel(1, 1, false), new Pixel(2, 1, false) }; var viewer = new[] { new Pixel[0], new[] { new Pixel(0, 1, isOn: false), new Pixel(1, 1, isOn: true), new Pixel(2, 1, isOn: false) }, new Pixel[0] }; Pixel[] actual = null; var mockViewer = new Mock <IPixelViewer>(); mockViewer.Setup(a => a.Rows).Returns(() => viewer); mockViewer.Setup(a => a.Update(It.IsAny <Pixel[]>())).Callback <Pixel[]>(pixels => actual = pixels); var sut = new RotateRowCommand(1, 2); sut.Update(mockViewer.Object); Assert.True(expectedRow.SequenceEqual(actual)); }