feature/edit/subset (#283)

* Changing query/subset API to only use Result on success, Error on error

* Creating an interservice API for getting query result subsets

* Updates to subset API

* RowStartIndex is now long
* Output of query/subset is a 2D array of DbCellValue
* Adding LongSkip method to LongList to allow skipping ahead by longs
* Moving LongList back to ServiceLayer utilities. Move refactoring

* Stubbing out request for edit/subset

* Initial implementation of getting edit rows

* Unit tests for RowEdit and RowDelete .GetEditRow

* Fixing major bugs in LongList implementation, adding much more thorough tests

* Adding some more unit tests and fixes to make unit tests pass

* Fixing comment
This commit is contained in:
Benjamin Russell
2017-03-21 15:14:04 -07:00
committed by GitHub
parent 9e576dea92
commit d7ecfb1a87
26 changed files with 1165 additions and 165 deletions

View File

@@ -12,6 +12,7 @@ using Microsoft.SqlTools.ServiceLayer.EditData;
using Microsoft.SqlTools.ServiceLayer.EditData.Contracts;
using Microsoft.SqlTools.ServiceLayer.EditData.UpdateManagement;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Xunit;
@@ -181,6 +182,64 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.EditData
Assert.Throws<InvalidOperationException>(() => rc.GetCommand(mockConn));
}
[Fact]
public void GetEditRowNoAdditions()
{
// Setup: Generate a standard row create
RowCreate rc = 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)
Assert.Equal(rc.newCells.Length, er.Cells.Length);
Assert.All(er.Cells, dbc =>
{
Assert.Equal(string.Empty, dbc.DisplayValue);
Assert.False(dbc.IsNull);
});
}
[Fact]
public void GetEditRowWithAdditions()
{
// Setp: Generate a row create with a cell added to it
RowCreate rc = GetStandardRowCreate();
rc.SetCell(0, "foo");
// 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
Assert.Equal("foo", er.Cells[0].DisplayValue);
Assert.False(er.Cells[0].IsNull);
// ... The rest of the cells should be blank
for (int i = 1; i < er.Cells.Length; i++)
{
DbCellValue dbc = er.Cells[i];
Assert.Equal(string.Empty, dbc.DisplayValue);
Assert.False(dbc.IsNull);
}
}
[Theory]
[InlineData(-1)] // Negative
[InlineData(3)] // At edge of acceptable values