示例#1
0
        public void ShouldReadValuesFromFlyWeight()
        {
            var table = new ReactiveTable <TestModelFlyweight>();

            Check.That(table.Columns).HasSize(4);
            CheckColumn(table, 0, "TestModelFlyweight.Id", typeof(int));
            CheckColumn(table, 1, "TestModelFlyweight.Name", typeof(string));
            CheckColumn(table, 2, "TestModelFlyweight.Value", typeof(decimal));
            CheckColumn(table, 3, "TestModelFlyweight.Timestamp", typeof(DateTime));

            var row = table.AddRow();

            table.SetValue("TestModelFlyweight.Id", row, 42);
            table.SetValue("TestModelFlyweight.Name", row, "Hello");
            table.SetValue("TestModelFlyweight.Value", row, 43m);
            var dateTime = DateTime.UtcNow;

            table.SetValue("TestModelFlyweight.Timestamp", row, dateTime);

            var flyweight = table.Flyweights[0];

            Check.That(flyweight.Id).IsEqualTo(42);
            Check.That(flyweight.Name).IsEqualTo("Hello");
            Check.That(flyweight.Value).IsEqualTo(43m);
            Check.That(flyweight.Timestamp).IsEqualTo(dateTime);
        }
示例#2
0
 protected void UpdateEntry(int rowIndex)
 {
     Table.SetValue(ValueCol, rowIndex, 98598643543m);
     Table.SetValue(TextCol, rowIndex, "An updated string");
     Table.SetValue(ValueCol, rowIndex, 9857437.3543m);
     Table.SetValue(DoubleCol, rowIndex, 94357348.43);
     Table.SetValue(BoolCol, rowIndex, false);
 }
        public void Iterate()
        {
            var id = _table.AddRow();

            _table.SetValue("IdCol", id, 1);
            _table.SetValue("TextCol", id, "Some longer string that should take up some more space");
            _table.SetValue("ValueCol", id, 23213214214.3423m);
        }
        private void AddRow(string groupVal, int value)
        {
            var row1 = _table1.AddRow();

            _table1.SetValue(GroupColumnId, row1, groupVal);
            _table1.SetValue(ValueColumnId, row1, value);
            _highWaterMark = Math.Max(_table1.RowCount, _highWaterMark);
        }
        public void Iterate()
        {
            var id = _table.AddRow();

            _table.SetValue("IdCol", id, 1);
            _table.SetValue("TextCol", id, "Some longer string that should take up some more space");
            _table.SetValue("ValueCol", id, 23213214214.3423m);

            var calc1 = _table.GetValue <decimal>("CalcCol1", id);
            var calc2 = _table.GetValue <string>("CalcCol2", id);
        }
        private static void AddValuesInReverseOrder(int count, ReactiveTable sourceTable, int startIndex = 0)
        {
            var end = startIndex + count - 1;

            for (var i = end; i >= startIndex; i--)
            {
                var rowId = sourceTable.AddRow();
                var id    = i;
                sourceTable.SetValue(TestTableColumns.IdColumn, rowId, id);
                sourceTable.SetValue(TestTableColumns.StringColumn, rowId, $"Item #{id.ToString("0000")}");
            }
        }
        private void TestSyncrhonisedDuplicate(int rowCount)
        {
            var uiTable   = TableTestHelper.CreateReactiveTable();
            var wireTable = new ReactiveTable(uiTable);

            new TableSynchroniser(wireTable, 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);
            }
        }
示例#8
0
        public void Iterate()
        {
            var id = _table.AddRow();

            _table.SetValue("IdCol", id, 1);
            _table.SetValue("TextCol", id, "Some longer string that should take up some more space");
            _table.SetValue("ValueCol1", id, 23213214214.3423m);
            _table.SetValue("ValueCol2", id, 23213214214.3423d);
            _table.SetValue("ValueCol3", id, 23213214214.3423f);
            _table.SetValue("ValueCol4", id, true);
            _table.SetValue("ValueCol5", id, "Another long string");
            _table.SetValue("ValueCol6", id, DateTime.Now);
        }
示例#9
0
        public void ShouldFlyweightShouldNotifyOfChanges()
        {
            var table = new ReactiveTable <TestModelFlyweight>();

            var row       = table.AddRow();
            var flyweight = table.Flyweights[0];

            var changes = new List <string>();

            flyweight.PropertyChanged += (sender, args) => changes.Add(args.PropertyName);

            table.SetValue("TestModelFlyweight.Id", row, 42);
            table.SetValue("TestModelFlyweight.Name", row, "Hello");
            table.SetValue("TestModelFlyweight.Value", row, 43m);
            var dateTime = DateTime.UtcNow;

            table.SetValue("TestModelFlyweight.Timestamp", row, dateTime);

            Check.That(changes).ContainsExactly("Id", "Name", "Value", "Timestamp");
        }
示例#10
0
        public void UpdateTestRow(ReactiveTable table, int rowId, bool includeComplexTypes = true)
        {
            table.SetValue(TestTableColumns.IdColumn, rowId, 2);
            table.SetValue(TestTableColumns.StringColumn, rowId, "Bar");
            table.SetValue(TestTableColumns.BoolColumn, rowId, true);
            table.SetValue(TestTableColumns.DoubleColumn, rowId, 2222.23);
            table.SetValue(TestTableColumns.ShortColumn, rowId, (short)3131);
            table.SetValue(TestTableColumns.LongColumn, rowId, 11111111111111);
            table.SetValue(TestTableColumns.DecimalColumn, rowId, 7678.232m);

            if (includeComplexTypes)
            {
                table.SetValue(TestTableColumns.DateTimeColumn, rowId, new DateTime(1983, 07, 03));
                table.SetValue(TestTableColumns.TimespanColumn, rowId, TimeSpan.FromHours(1));
                table.SetValue(TestTableColumns.GuidColumn, rowId, Guid.NewGuid());
            }

            table.SetValue(TestTableColumns.FloatColumn, rowId, 1.2343f);
            table.SetValue(TestTableColumns.ByteColumn, rowId, (byte)234);
            table.SetValue(TestTableColumns.CharColumn, rowId, 'a');
        }
示例#11
0
        public static int AddTestRow(ReactiveTable table, bool includeComplexTypes = true)
        {
            var rowId = table.AddRow();

            table.SetValue(TestTableColumns.IdColumn, rowId, 1);
            table.SetValue(TestTableColumns.StringColumn, rowId, "Foo");
            table.SetValue(TestTableColumns.BoolColumn, rowId, false);
            table.SetValue(TestTableColumns.DoubleColumn, rowId, 1111.232);
            table.SetValue(TestTableColumns.ShortColumn, rowId, (short)4242);
            table.SetValue(TestTableColumns.LongColumn, rowId, 22222222222222);
            table.SetValue(TestTableColumns.DecimalColumn, rowId, 2132.233m);

            if (includeComplexTypes)
            {
                table.SetValue(TestTableColumns.DateTimeColumn, rowId, new DateTime(1982, 04, 10));
                table.SetValue(TestTableColumns.TimespanColumn, rowId, TimeSpan.FromDays(1));
                table.SetValue(TestTableColumns.GuidColumn, rowId, Guid.NewGuid());
            }

            table.SetValue(TestTableColumns.FloatColumn, rowId, 6.6542f);
            table.SetValue(TestTableColumns.ByteColumn, rowId, (byte)188);
            table.SetValue(TestTableColumns.CharColumn, rowId, 'D');
            return(rowId);
        }
示例#12
0
 public static void SetAndTestValueNotPresent <T>(ReactiveTable setTable, ReactiveTable getTable, int setRowId, int getRowId, T value, string columnId)
 {
     setTable.SetValue(columnId, setRowId, value);
     Assert.AreEqual(default(T), getTable.GetValue <T>(columnId, getRowId));
 }
示例#13
0
 public static void SetAndTestValue <T>(ReactiveTable setTable, ReactiveTable getTable, int setRowId, int getRowId, T value, string columnId)
 {
     setTable.SetValue(columnId, setRowId, value);
     TestValue(getTable, getRowId, value, columnId);
 }
示例#14
0
 public static void SetAndTestValue <T>(ReactiveTable table, int rowId, T value, string columnId)
 {
     table.SetValue(columnId, rowId, value);
     Assert.AreEqual(value, table.GetValue <T>(columnId, rowId));
 }
 public void SetValue <T>(string columnId, int rowIndex, T value)
 {
     _marshaller.Dispatch(() => _targetTargetTable.SetValue(columnId, rowIndex, value));
 }