private static void TestAdd(ReactiveBatchedPassThroughTable source, ReactiveTable target, RowUpdateHandler updateHandler) { var sourceRow1 = source.AddRow(); Assert.AreEqual(0, target.RowCount); TestTableHelper.SetAndTestValueNotPresent(source, target, sourceRow1, updateHandler.LastRowUpdated, 101, TestTableColumns.IdColumn); TestTableHelper.SetAndTestValueNotPresent(source, target, sourceRow1, updateHandler.LastRowUpdated, "Blah", TestTableColumns.StringColumn); TestTableHelper.SetAndTestValueNotPresent(source, target, sourceRow1, updateHandler.LastRowUpdated, 4324m, TestTableColumns.DecimalColumn); var sourceRow2 = source.AddRow(); Assert.AreEqual(0, target.RowCount); TestTableHelper.SetAndTestValueNotPresent(source, target, sourceRow2, updateHandler.LastRowUpdated, 102, TestTableColumns.IdColumn); TestTableHelper.SetAndTestValueNotPresent(source, target, sourceRow2, updateHandler.LastRowUpdated, "Blah2", TestTableColumns.StringColumn); TestTableHelper.SetAndTestValueNotPresent(source, target, sourceRow2, updateHandler.LastRowUpdated, 42m, TestTableColumns.DecimalColumn); source.SynchroniseChanges(); Assert.AreEqual(2, target.RowCount); TestTableHelper.TestValue(target, updateHandler.RowsUpdated[0], 101, TestTableColumns.IdColumn); TestTableHelper.TestValue(target, updateHandler.RowsUpdated[0], "Blah", TestTableColumns.StringColumn); TestTableHelper.TestValue(target, updateHandler.RowsUpdated[0], 4324m, TestTableColumns.DecimalColumn); TestTableHelper.TestValue(target, updateHandler.RowsUpdated[1], 102, TestTableColumns.IdColumn); TestTableHelper.TestValue(target, updateHandler.RowsUpdated[1], "Blah2", TestTableColumns.StringColumn); TestTableHelper.TestValue(target, updateHandler.RowsUpdated[1], 42m, TestTableColumns.DecimalColumn); }
public void TestDelete() { var target = TestTableHelper.CreateReactiveTable(); var source = new ReactiveBatchedPassThroughTable(target, new DefaultThreadMarshaller()); var updateHandler = new RowUpdateHandler(); target.RowUpdates().Subscribe(updateHandler.OnRowUpdate); TestAdd(source, target, updateHandler); source.DeleteRow(0); Assert.AreEqual(2, target.RowCount); source.SynchroniseChanges(); Assert.AreEqual(1, target.RowCount); Assert.AreEqual(102, target.GetValue <int>(TestTableColumns.IdColumn, 1)); source.DeleteRow(1); Assert.AreEqual(1, target.RowCount); source.SynchroniseChanges(); Assert.AreEqual(0, target.RowCount); source.AddRow(); Assert.AreEqual(0, target.RowCount); source.SynchroniseChanges(); Assert.AreEqual(1, target.RowCount); }
private void TestSyncrhonisedBatchPassThrough(int rowCount) { var uiTable = TableTestHelper.CreateReactiveTable(); var delay = TimeSpan.FromMilliseconds(250); var wireTable = new ReactiveBatchedPassThroughTable(uiTable, new DefaultThreadMarshaller(), delay); for (var i = 0; i < rowCount; i++) { var rowIndex = wireTable.AddRow(); wireTable.SetValue(TestTableColumns.IdColumn, rowIndex, i); wireTable.SetValue(TestTableColumns.StringColumn, rowIndex, $"Entry {i}"); wireTable.SetValue(TestTableColumns.DecimalColumn, rowIndex, (decimal)i); } while (wireTable.GetRowUpdateCount() > 0) { Thread.Sleep(100); } Thread.Sleep(600); Assert.AreEqual(uiTable.RowCount, wireTable.RowCount); }