예제 #1
0
        public void FillObjectSchemeDegradeTest()
        {
            //This call will generate full schema
            FillObjectTest();

            //now tying to load from degrade scheme
            DataTable dt = _DateTable.Copy();

            dt.Columns.RemoveAt(4);
            dt.Columns.RemoveAt(3);
            dt.Columns.RemoveAt(2);
            dt.Columns.RemoveAt(1);

            TesterAll tester = new TesterAll();

            //DataMapper.Default.ClearCache();
            //DataMapper.Default.SetConfig(null);
            //DataMapper.Default.SaveGeneratedAsm("asm1.dll");

            DataMapper.Default.FillObject(dt.Rows[0], tester, 0);

            if (tester.ValueProp != 72 ||
                tester.ValuePropNI != true ||
                tester.RefProp != null ||
                tester.StructProp != DateTime.MinValue ||
                tester.NullableProp != null ||
                tester.NullablePropBool != true ||
                tester.TesterArrayList.Count != 0 ||
                tester.TesterList.Count != 0 ||
                tester.CmplProp.StructProp != DateTime.MinValue
                )
            {
                Assert.Fail("FillObjectTest fails.");
            }
        }
예제 #2
0
        public void FillObjectTest()
        {
            TesterAll tester = new TesterAll();

            DataMapper.Default.ClearCache();
            DataMapper.Default.SetConfig(String.Empty);


            DataMapper.Default.FillObject(_DateTable.Rows[0], tester, 0);
            if (tester.ValueProp != 72 ||
                tester.ValuePropNI != true ||
                tester.RefProp != "Hey!" ||
                tester.StructProp != _CurrentDate ||
                tester.NullableProp != _CurrentDate ||
                tester.NullablePropBool != true ||
                tester.TesterArrayList.Count != 2 ||
                tester.TesterList.Count != 2 ||
                tester.CmplProp.StructProp != _CurrentDate ||
                tester.StrProp != "72" ||
                tester.EnumProp != TestEnum.First
                )
            {
                Assert.Fail("FillObjectTest fails.");
            }


            DataMapper.Default.FillObject(_DateTable.Rows[2], tester, 0);
            if (tester.ValueProp != default(int) ||
                tester.ValuePropNI != default(bool) ||
                tester.RefProp != null ||
                tester.StructProp != default(DateTime) ||
                tester.NullableProp != null ||
                tester.NullablePropBool != null ||
                tester.TesterArrayList.Count != 2 ||
                tester.TesterList.Count != 2 ||
                tester.CmplProp.StructProp != default(DateTime) ||
                tester.StrProp != null ||
                tester.EnumProp != TestEnum.None
                )
            {
                Assert.Fail("FillObjectTest with DBNull fails.");
            }


            DataMapper.Default.FillObject(_DateTable.Rows[3], tester, 0);
            if (tester.ValueProp != 0 ||
                tester.ValuePropNI != false ||
                tester.RefProp != "Twice" ||
                tester.StructProp != DateTime.MaxValue ||
                tester.NullableProp != DateTime.MaxValue ||
                tester.NullablePropBool != false ||
                tester.StrProp != "0"
                //result.TesterArrayList.Count != 1 ||
                //result.TesterList.Count != 1
                )
            {
                Assert.Fail("FillObjectsTest fails.");
            }
        }
예제 #3
0
        public void FillObjectTestXML()
        {
            TesterAll tester = new TesterAll();

            DataMapper.Default.ClearCache();
            DataMapper.Default.SetConfig(@"..\..\..\DataMapperTest\datatable.mapping");
            DataMapper.Default.FillObject(_DateTable.Rows[0], tester, 0);

            if (tester.ValueProp != 72 ||
                tester.ValuePropNI != true ||
                tester.RefProp != "Hey!" ||
                tester.StructProp != _CurrentDate ||
                tester.NullableProp != _CurrentDate ||
                tester.NullablePropBool != true ||
                tester.TesterArrayList.Count != 2 ||
                tester.TesterList.Count != 2 ||
                tester.CmplProp.StructProp != _CurrentDate
                )
            {
                Assert.Fail("FillObjectTest fails.");
            }

            DataMapper.Default.FillObject(_DateTable.Rows[2], tester, 0);

            if (tester.ValueProp != default(int) ||
                tester.ValuePropNI != default(bool) ||
                tester.RefProp != null ||
                tester.StructProp != default(DateTime) ||
                tester.NullableProp != null ||
                tester.NullablePropBool != null ||
                tester.TesterArrayList.Count != 2 ||
                tester.TesterList.Count != 2 ||
                tester.CmplProp.StructProp != default(DateTime)
                )
            {
                Assert.Fail("FillObjectTest with DBNull fails.");
            }
        }
예제 #4
0
        public void FillObjectReaderTest()
        {
            DataMapper.Default.ClearCache();
            DataMapper.Default.SetConfig(String.Empty);

            TesterAll result = new TesterAll();
            var       reader = _DataSet.CreateDataReader();

            DataMapper.Default.FillObject(reader, result);

            if (result.ValueProp != 72 ||
                result.ValuePropNI != true ||
                result.RefProp != "Hey!" ||
                result.StructProp != _CurrentDate ||
                result.NullableProp != _CurrentDate ||
                result.NullablePropBool != true ||
                result.StrProp != "72" ||
                result.EnumProp != TestEnum.First
                //result.TesterArrayList.Count != 2 ||
                //result.TesterList.Count != 2
                )
            {
                Assert.Fail("FillObjectTest fails.");
            }

            result = DataMapper.Default.FillObject <TesterAll>(reader, null);
            if (result.ValueProp != 34 ||
                result.ValuePropNI != true ||
                result.RefProp != "Twice" ||
                result.StructProp != DateTime.MaxValue ||
                result.NullableProp != DateTime.MaxValue ||
                result.NullablePropBool != true ||
                result.StrProp != "34" ||
                result.EnumProp != TestEnum.Second
                //result.TesterArrayList.Count != 1 ||
                //result.TesterList.Count != 1
                )
            {
                Assert.Fail("FillObjectsTest fails.");
            }

            result = DataMapper.Default.FillObject <TesterAll>(reader, null);
            if (result.ValueProp != default(int) ||
                result.ValuePropNI != default(bool) ||
                result.RefProp != null ||
                result.StructProp != default(DateTime) ||
                result.NullableProp != null ||
                result.NullablePropBool != null ||
                result.StrProp != null ||
                result.EnumProp != TestEnum.None
                //result.TesterArrayList.Count != 1 ||
                //result.TesterList.Count != 1
                )
            {
                Assert.Fail("FillObjectsTest fails.");
            }

            result = DataMapper.Default.FillObject <TesterAll>(reader, null);
            if (result.ValueProp != 0 ||
                result.ValuePropNI != false ||
                result.RefProp != "Twice" ||
                result.StructProp != DateTime.MaxValue ||
                result.NullableProp != DateTime.MaxValue ||
                result.NullablePropBool != false ||
                result.StrProp != "0"
                //result.TesterArrayList.Count != 1 ||
                //result.TesterList.Count != 1
                )
            {
                Assert.Fail("FillObjectsTest fails.");
            }

            reader.Close();
        }