public async Task GetEditNullRow() { // Setup: Create a row update RowUpdate ru = await GetStandardRowUpdate(); // If: I attempt to get an edit row with a null cached row // Then: I should get an exception Assert.Throws <ArgumentNullException>(() => ru.GetEditRow(null)); }
public async Task GetEditRow() { // Setup: Create a row update with a cell set 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, "foo"); // If: I attempt to get an edit row DbCellValue[] cells = rs.GetRow(0).ToArray(); EditRow er = ru.GetEditRow(cells); // Then: // ... The state should be dirty Assert.True(er.IsDirty); Assert.Equal(EditRow.EditRowState.DirtyUpdate, er.State); // ... The ID should be the same as the one provided Assert.Equal(0, er.Id); // ... The row should match the cells that were given, except for the updated cell Assert.Equal(cells.Length, er.Cells.Length); for (int i = 1; i < cells.Length; i++) { DbCellValue originalCell = cells[i]; DbCellValue outputCell = er.Cells[i]; Assert.Equal(originalCell.DisplayValue, outputCell.DisplayValue); Assert.Equal(originalCell.IsNull, outputCell.IsNull); // Note: No real need to check the RawObject property } // ... The updated cell should match what it was set to and be dirty EditCell newCell = er.Cells[0]; Assert.Equal("foo", newCell.DisplayValue); Assert.False(newCell.IsNull); Assert.True(newCell.IsDirty); }