public async Task RevertCellRevertsRow() { // Setup: // ... Create a row update var columns = Common.GetColumns(false); var rs = await Common.GetResultSet(columns, false); var etm = Common.GetStandardMetadata(columns); RowUpdate ru = new RowUpdate(0, rs, etm); ru.SetCell(0, "qqq"); // If: I attempt to revert a cell that was set EditRevertCellResult result = ru.RevertCell(0); // Then: // ... We should get a result back Assert.NotNull(result); // ... We should get the original value back // @TODO: Check for a default value when we support it Assert.NotNull(result.Cell); Assert.Equal(rs.GetRow(0)[0].DisplayValue, result.Cell.DisplayValue); // ... The row should now be reverted Assert.False(result.IsRowDirty); // ... The cell should no longer be set Assert.DoesNotContain(0, ru.cellUpdates.Keys); }
public async Task RevertCellThatWasSet() { // Setup: // ... Create a row update var data = new Common.TestDbColumnsWithTableMetadata(false, false, 0, 0); var rs = await Common.GetResultSet(data.DbColumns, false); RowUpdate ru = new RowUpdate(0, rs, data.TableMetadata); ru.SetCell(0, "qqq"); ru.SetCell(1, "qqq"); // If: I attempt to revert a cell that was set EditRevertCellResult result = ru.RevertCell(0); // Then: // ... We should get a result back Assert.NotNull(result); // ... We should get the original value back // @TODO: Check for a default value when we support it Assert.NotNull(result.Cell); Assert.Equal(rs.GetRow(0)[0].DisplayValue, result.Cell.DisplayValue); // ... The row should be dirty still Assert.True(result.IsRowDirty); // ... The cell should no longer be set Assert.DoesNotContain(0, ru.cellUpdates.Keys); }
[InlineData(100)] // Way too large value public async Task RevertCellOutOfRange(int columnId) { // Setup: // ... Create a row update (no cell updates needed) var data = new Common.TestDbColumnsWithTableMetadata(false, false, 0, 0); var rs = await Common.GetResultSet(data.DbColumns, false); RowUpdate ru = new RowUpdate(0, rs, data.TableMetadata); // If: I attempt to revert a cell that is out of range // Then: I should get an exception Assert.Throws <ArgumentOutOfRangeException>(() => ru.RevertCell(columnId)); }
[InlineData(100)] // Way too large value public async Task RevertCellOutOfRange(int columnId) { // Setup: // ... Create a row update (no cell updates needed) var columns = Common.GetColumns(false); var rs = await Common.GetResultSet(columns, false); var etm = Common.GetStandardMetadata(columns); RowUpdate ru = new RowUpdate(0, rs, etm); // If: I attempt to revert a cell that is out of range // Then: I should get an exception Assert.Throws <ArgumentOutOfRangeException>(() => ru.RevertCell(columnId)); }