Example #1
0
        public void Test_Map_Object_DataType_To_Strongly_Type_Class()
        {
            var dataReader = GetData().CreateDataReader();

            var list     = dataReader.MapToList <StringDataType>();
            var instance = list.First();

            ObjectDataTypeAccessor.GetMembers().ToList().ForEach(delegate(Member member)
            {
                var expectedValue = ObjectDataTypeAccessor[Instance, member.Name];
                var actualValue   = StringAccessor[instance, member.Name];
                Assert.AreEqual(expectedValue?.ToString(), actualValue, $"MapToList gave the property {member.Name} The wrong value. Expected {expectedValue} but it was {actualValue}");
            });
        }
Example #2
0
        private static DataTable GetData()
        {
            var table = new DataTable();

            ObjectDataTypeAccessor.GetMembers().ToList().ForEach(delegate(Member member)
            {
                table.Columns.Add(member.Name, member.Type);
            });

            var values = new List <object>()
            {
            };

            ObjectDataTypeAccessor.GetMembers().ToList().ForEach(delegate(Member member)
            {
                values.Add(ObjectDataTypeAccessor[Instance, member.Name]);
            });
            table.Rows.Add(values.ToArray());
            table.AcceptChanges();
            return(table);
        }