public async Task GetEditRowWithAdditions() { // Setp: Generate a row create with a cell added to it RowCreate rc = await GetStandardRowCreate(); const string setValue = "foo"; rc.SetCell(0, setValue); // If: I request an edit row from the row create EditRow er = rc.GetEditRow(null); // Then: // ... The row should not be null and contain the same number of cells as columns Assert.NotNull(er); Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State); // ... The row should not be clean Assert.True(er.IsDirty); Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State); // ... The row should have a single non-empty cell at the beginning that is dirty Assert.Equal(setValue, er.Cells[0].DisplayValue); Assert.False(er.Cells[0].IsNull); Assert.True(er.Cells[0].IsDirty); // ... The rest of the cells should be blank, but dirty for (int i = 1; i < er.Cells.Length; i++) { EditCell ec = er.Cells[i]; Assert.Equal(string.Empty, ec.DisplayValue); Assert.False(ec.IsNull); Assert.True(ec.IsDirty); } }
public async Task GetEditRowWithDefaultValue() { // Setup: Generate a row create with default values const long rowId = 100; Common.TestDbColumnsWithTableMetadata data = new Common.TestDbColumnsWithTableMetadata(false, false, 3, 0); ResultSet rs = await Common.GetResultSet(data.DbColumns, false); RowCreate rc = new RowCreate(rowId, rs, data.TableMetadata); // If: I request an edit row from the row create EditRow er = rc.GetEditRow(null); // Then: // ... The row should not be null Assert.NotNull(er); // ... The row should not be clean Assert.True(er.IsDirty); Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State); // ... The row sould have a bunch of default values (equal to number of columns) and all are dirty Assert.Equal(rc.newCells.Length, er.Cells.Length); Assert.All(er.Cells, ec => { Assert.Equal(Common.DefaultValue, ec.DisplayValue); Assert.False(ec.IsNull); // TODO: Update when we support null default values better Assert.True(ec.IsDirty); }); }
public async Task GetEditRowNoAdditions() { // Setup: Generate a standard row create RowCreate rc = await GetStandardRowCreate(); // If: I request an edit row from the row create EditRow er = rc.GetEditRow(null); // Then: // ... The row should not be null Assert.NotNull(er); // ... The row should not be clean Assert.True(er.IsDirty); Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State); // ... The row should have a bunch of empty cells (equal to number of columns) and all are dirty Assert.Equal(rc.newCells.Length, er.Cells.Length); Assert.All(er.Cells, ec => { Assert.Equal(string.Empty, ec.DisplayValue); Assert.False(ec.IsNull); Assert.True(ec.IsDirty); }); }
public async Task GetEditRowWithCalculatedValue() { // Setup: Generate a row create with an identity column const long rowId = 100; Common.TestDbColumnsWithTableMetadata data = new Common.TestDbColumnsWithTableMetadata(false, true, 0, 0); ResultSet rs = await Common.GetResultSet(data.DbColumns, true); RowCreate rc = new RowCreate(rowId, rs, data.TableMetadata); // If: I request an edit row from the row created EditRow er = rc.GetEditRow(null); // Then: // ... The row should not be null Assert.NotNull(er); Assert.Equal(er.Id, rowId); // ... The row should not be clean Assert.True(er.IsDirty); Assert.Equal(EditRow.EditRowState.DirtyInsert, er.State); // ... The row should have a TBD for the identity column Assert.Equal(rc.newCells.Length, er.Cells.Length); Assert.Equal(SR.EditDataComputedColumnPlaceholder, er.Cells[0].DisplayValue); Assert.False(er.Cells[0].IsNull); Assert.True(er.Cells[0].IsDirty); // ... The rest of the cells should have empty display values Assert.All(er.Cells.Skip(1), ec => { Assert.Equal(string.Empty, ec.DisplayValue); Assert.False(ec.IsNull); Assert.True(ec.IsDirty); }); }