Example #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);
        }
        private void TestSyncrhonisedPassThrough(int rowCount)
        {
            var uiTable   = TableTestHelper.CreateReactiveTable();
            var wireTable = new ReactivePassThroughTable(uiTable, new DefaultThreadMarshaller());

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

            Assert.AreEqual(uiTable.RowCount, wireTable.RowCount);
        }