Пример #1
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));
        }
Пример #2
0
        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);
        }
Пример #3
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));
        }