public void TestClipboard() { var backup = new Backup <BimaruGrid>(); var grid = new BimaruGrid(1, 2); var p0 = new GridPoint(0, 0); var p1 = new GridPoint(0, 1); grid[p0] = BimaruValue.SHIP_CONT_UP; grid[p1] = BimaruValue.SHIP_CONT_DOWN; backup.CloneToClipboard(grid); grid[p0] = BimaruValue.SHIP_SINGLE; grid[p1] = BimaruValue.WATER; backup.RestoreFromClipboardTo(grid); BimaruValue[,] expectedFieldValues; expectedFieldValues = new BimaruValue[1, 2] { { BimaruValue.SHIP_CONT_UP, BimaruValue.SHIP_CONT_DOWN } }; grid.AssertEqual(expectedFieldValues); }
public void TestRestoreEmptyClipBoard() { var backup = new Backup <BimaruGrid>(); var grid = new BimaruGrid(1, 1); Assert.ThrowsException <InvalidOperationException>(() => backup.RestoreFromClipboardTo(grid)); }
public void TestStackOperations() { var backup = new Backup <BimaruGrid>(); var grid = new BimaruGrid(1, 2); var p0 = new GridPoint(0, 0); var p1 = new GridPoint(0, 1); grid[p0] = BimaruValue.SHIP_SINGLE; grid[p1] = BimaruValue.WATER; backup.SetSavePoint(grid); grid[p0] = BimaruValue.SHIP_CONT_DOWN; grid[p1] = BimaruValue.UNDETERMINED; backup.RestoreAndDeleteLastSavepoint(grid); BimaruValue[,] expectedFieldValues = new BimaruValue[1, 2] { { BimaruValue.SHIP_SINGLE, BimaruValue.WATER } }; grid.AssertEqual(expectedFieldValues); AssertEmptyStack(backup); }
public Game GenerateEmptyGame(int numRows, int numColumns) { var rowTally = new GridTally(numRows); var columnTally = new GridTally(numColumns); var shipSettings = new ShipTarget(); var grid = new BimaruGrid(numRows, numColumns); return(new Game(rowTally, columnTally, shipSettings, grid)); }
private void AssertEmptyStack(Backup <BimaruGrid> backup) { var destination = new BimaruGrid(1, 1); Assert.ThrowsException <InvalidOperationException>(() => backup.RestoreAndDeleteLastSavepoint(destination)); }