Esempio n. 1
0
        private void SetEntity(SchemaMappingColumn[] additionalColumns, string[] sortNames, object[][] data)
        {
            additionalColumns = additionalColumns ?? new SchemaMappingColumn[0];
            var schemaMapping = DataSourceBuilder.BuildSchemaMappingFromEntityMapping(_mapper, additionalColumns);
            var columns       = schemaMapping.Columns.ToArray();

            SchemaMappingColumn.SortByName(columns, sortNames);
            var dataReader   = DataSourceBuilder.BuildDataReader(columns, data);
            var entityReader = new EntityReader <NotNullEntity>(_mapper, dataReader.GetSchemaTable());

            dataReader.Read();
            entityReader.SetEntity(dataReader, _entity);
        }
        public void BuildDataReader()
        {
            var data = new[]
            {
                new object[] { 1, "row1", DateTime.Now },
                new object[] { 2, "row2", DateTime.Now },
            };
            var reader = DataSourceBuilder.BuildDataReader(TestColumns, data);
            var schema = reader.GetSchemaTable();

            AssertSchemaTable(schema, TestColumns);

            Assert.IsTrue(reader.Read());
            CollectionAssert.AreEqual(data[0], new object[] { reader[0], reader[1], reader[2] });

            Assert.IsTrue(reader.Read());
            CollectionAssert.AreEqual(data[1], new object[] { reader[0], reader[1], reader[2] });

            Assert.IsFalse(reader.Read());
        }