public async Task RevertCellThatWasSet(int defaultCols) { // Setup: // ... Generate the parameters for the row create Common.TestDbColumnsWithTableMetadata data = new Common.TestDbColumnsWithTableMetadata(false, false, defaultCols, 0); ResultSet rs = await Common.GetResultSet(data.DbColumns, false); RowCreate rc = new RowCreate(100, rs, data.TableMetadata); rc.SetCell(0, "1"); // If: I attempt to revert a cell that was set EditRevertCellResult result = rc.RevertCell(0); // Then: // ... We should get a result back Assert.NotNull(result); // ... We should get back an edit cell with a value based on the default value string expectedDisplayValue = defaultCols > 0 ? Common.DefaultValue : string.Empty; Assert.NotNull(result.Cell); Assert.Equal(expectedDisplayValue, result.Cell.DisplayValue); Assert.False(result.Cell.IsNull); // TODO: Modify to support null defaults // ... The row should be dirty Assert.True(result.IsRowDirty); // ... The cell should no longer be set Assert.Null(rc.newCells[0]); }
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); }
/// <summary> /// Reverts a cell in a pending edit /// </summary> /// <param name="rowId">Internal ID of the row to have its edits reverted</param> /// <param name="columnId">Ordinal ID of the column to revert</param> /// <returns>String version of the old value for the cell</returns> public EditRevertCellResult RevertCell(long rowId, int columnId) { ThrowIfNotInitialized(); // Attempt to get the row edit with the given ID RowEditBase pendingEdit; if (!EditCache.TryGetValue(rowId, out pendingEdit)) { throw new ArgumentOutOfRangeException(nameof(rowId), SR.EditDataUpdateNotPending); } // Update the row EditRevertCellResult revertResult = pendingEdit.RevertCell(columnId); CleanupEditIfRowClean(rowId, revertResult); // Have the edit base revert the cell return(revertResult); }
public async Task RevertCellNotSet() { // Setup: Generate the row create RowCreate rc = await GetStandardRowCreate(); // If: I attempt to revert a cell that has not been set EditRevertCellResult result = rc.RevertCell(0); // Then: // ... We should get a result back Assert.NotNull(result); // ... We should get a null cell back // @TODO: Check for a default value when we support it Assert.Null(result.Cell); // ... The row should be dirty Assert.True(result.IsRowDirty); // ... The cell should no longer be set Assert.Null(rc.newCells[0]); }