Пример #1
0
        public void TestUpdate()
        {
            var target = TestTableHelper.CreateReactiveTable();
            var source = new ReactivePassThroughTable(target, new DefaultThreadMarshaller());

            var updateHandler = new RowUpdateHandler();

            target.RowUpdates().Subscribe(updateHandler.OnRowUpdate);

            var sourceRow1 = source.AddRow();

            Assert.AreEqual(1, target.RowCount);

            TestTableHelper.SetAndTestValue(source, target, sourceRow1, updateHandler.LastRowUpdated, 101, TestTableColumns.IdColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow1, updateHandler.LastRowUpdated, "Blah", TestTableColumns.StringColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow1, updateHandler.LastRowUpdated, 4324m, TestTableColumns.DecimalColumn);

            TestTableHelper.SetAndTestValue(source, target, sourceRow1, updateHandler.LastRowUpdated, 103, TestTableColumns.IdColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow1, updateHandler.LastRowUpdated, "Blah2", TestTableColumns.StringColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow1, updateHandler.LastRowUpdated, 43999m, TestTableColumns.DecimalColumn);

            var sourceRow2 = source.AddRow();

            Assert.AreEqual(2, target.RowCount);

            TestTableHelper.SetAndTestValue(source, target, sourceRow2, updateHandler.LastRowUpdated, 102, TestTableColumns.IdColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow2, updateHandler.LastRowUpdated, "Blah2", TestTableColumns.StringColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow2, updateHandler.LastRowUpdated, 42m, TestTableColumns.DecimalColumn);

            TestTableHelper.SetAndTestValue(source, target, sourceRow2, updateHandler.LastRowUpdated, 104, TestTableColumns.IdColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow2, updateHandler.LastRowUpdated, "Blah4", TestTableColumns.StringColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow2, updateHandler.LastRowUpdated, 421111m, TestTableColumns.DecimalColumn);
        }
Пример #2
0
        public void TestUpdateOnlyLastValue()
        {
            var target = TestTableHelper.CreateReactiveTable();
            var source = new ReactiveBatchedPassThroughTable(target, new DefaultThreadMarshaller(), true);

            var rowUpdates = new RowUpdateHandler();

            target.RowUpdates().Subscribe(rowUpdates.OnRowUpdate);
            var columnUpdates = new ColumnUpdateHandler();

            target.ColumnUpdates().Subscribe(columnUpdates.OnColumnUpdate);

            TestAdd(source, target, rowUpdates);

            columnUpdates.LastColumnsUpdated.Clear();

            source.SetValue(TestTableColumns.StringColumn, 0, "Changed");
            Assert.AreEqual("Blah", target.GetValue <string>(TestTableColumns.StringColumn, 0));
            source.SetValue(TestTableColumns.StringColumn, 0, "Changed2");
            Assert.AreEqual("Blah", target.GetValue <string>(TestTableColumns.StringColumn, 0));

            source.SynchroniseChanges();

            // Check that there was only one col update fro the StringColumn
            Assert.AreEqual(1, columnUpdates.LastColumnsUpdated.Count);
            Assert.AreEqual(columnUpdates.LastColumnsUpdated.Last(), TestTableColumns.StringColumn);
            // And that the value is the last one
            Assert.AreEqual("Changed2", target.GetValue <string>(TestTableColumns.StringColumn, 0));
        }
Пример #3
0
        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);
        }
Пример #4
0
        public void TestAdd()
        {
            var target = TestTableHelper.CreateReactiveTable();
            var source = new ReactiveBatchedPassThroughTable(target, new DefaultThreadMarshaller());

            var updateHandler = new RowUpdateHandler();

            target.RowUpdates().Subscribe(updateHandler.OnRowUpdate);

            TestAdd(source, target, updateHandler);
        }
//        [Test]
        public void TestDelete()
        {
            var source       = TestTableHelper.CreateReactiveTable();
            var target       = TestTableHelper.CreateReactiveTable();
            var synchroniser = new BatchedTableSynchroniser(source, target, new DefaultThreadMarshaller(), TimeSpan.FromMilliseconds(delay));

            var updateHandler = new RowUpdateHandler();

            target.RowUpdates().Subscribe(updateHandler.OnRowUpdate);

            var sourceRow1 = source.AddRow();

            Assert.AreEqual(1, target.RowCount);

            TestTableHelper.SetAndTestValue(source, target, sourceRow1, updateHandler.LastRowUpdated, 101, TestTableColumns.IdColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow1, updateHandler.LastRowUpdated, "Blah", TestTableColumns.StringColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow1, updateHandler.LastRowUpdated, 4324m, TestTableColumns.DecimalColumn);

            var sourceRow2 = source.AddRow();

            Assert.AreEqual(2, target.RowCount);

            var targetRow2 = updateHandler.LastRowUpdated;

            TestTableHelper.SetAndTestValue(source, target, sourceRow2, updateHandler.LastRowUpdated, 102, TestTableColumns.IdColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow2, updateHandler.LastRowUpdated, "Blah2", TestTableColumns.StringColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow2, updateHandler.LastRowUpdated, 42m, TestTableColumns.DecimalColumn);

            source.DeleteRow(sourceRow1);
            Assert.AreEqual(1, target.RowCount);
            Assert.AreEqual(102, target.GetValue <int>(TestTableColumns.IdColumn, targetRow2));

            source.DeleteRow(sourceRow2);
            Assert.AreEqual(0, target.RowCount);

            var sourceRow3 = source.AddRow();

            Assert.AreEqual(1, target.RowCount);

            TestTableHelper.SetAndTestValue(source, target, sourceRow3, updateHandler.LastRowUpdated, 101, TestTableColumns.IdColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow3, updateHandler.LastRowUpdated, "Blah", TestTableColumns.StringColumn);
            TestTableHelper.SetAndTestValue(source, target, sourceRow3, updateHandler.LastRowUpdated, 4324m, TestTableColumns.DecimalColumn);
        }
Пример #6
0
        public void TestUpdate()
        {
            var target = TestTableHelper.CreateReactiveTable();
            var source = new ReactiveBatchedPassThroughTable(target, new DefaultThreadMarshaller());

            var rowUpdates = new RowUpdateHandler();

            target.RowUpdates().Subscribe(rowUpdates.OnRowUpdate);
            var columnUpdates = new ColumnUpdateHandler();

            target.ColumnUpdates().Subscribe(columnUpdates.OnColumnUpdate);

            TestAdd(source, target, rowUpdates);

            source.SetValue(TestTableColumns.StringColumn, 0, "Changed");
            Assert.AreEqual("Blah", target.GetValue <string>(TestTableColumns.StringColumn, 0));

            source.SynchroniseChanges();

            Assert.AreEqual("Changed", target.GetValue <string>(TestTableColumns.StringColumn, 0));
        }
        public void TestAdd()
        {
            var source       = TestTableHelper.CreateReactiveTable();
            var target       = TestTableHelper.CreateReactiveTable();
            var synchroniser = new BatchedTableSynchroniser(source, target, new DefaultThreadMarshaller(), TimeSpan.FromMilliseconds(delay));

            var updateHandler = new RowUpdateHandler();

            target.RowUpdates().Subscribe(updateHandler.OnRowUpdate);

            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);

            Thread.Sleep(delay + 50);
            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);
        }
Пример #8
0
        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);
        }