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 RectangleCommand_CreatedCorrectly() { var expected = new TurnOnPixelsInRectangleCommand(3, 2); var mockViewer = new Mock <IPixelViewer>(); var commandStrings = new[] { "rect 3x2" }; var commands = new PixelViewerCommandFactory().Create(() => commandStrings); Assert.Equal(1, commands.Count()); Assert.Equal(expected, commands.First()); }
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()); }
public static void Problem8() { var screen = new Screen(); var commands = new PixelViewerCommandFactory().Create(() => FileStringReader.Read("P8.txt")); commands.Process(screen); var display = new RowBasedPixelViewerDisplay(screen, s => Console.WriteLine(s)); display.Refresh(); var on = screen.Rows.Select(a => a.Count(b => b.IsOn)).Sum(); Console.WriteLine("\nNumber On = {0}", on); }