public void DbResultToSampleObjectAllowMissing()
        {
            const string mandatoryField         = "Mandatory";
            const int    expectedMandatoryValue = 890;

            {
                DataTable dt = DatasetGenerator.CreateNewBasicDataTable(
                    new string[] { mandatoryField },
                    new Type[] { typeof(int) });

                using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt, expectedMandatoryValue))
                {
                    dr.Read();

                    SampleObject obj = new SampleObject();

                    DbAutoFillHelper.FillObjectFromDataReader(dr, obj);

                    Assert.AreEqual(expectedMandatoryValue, obj.Mandatory);
                }
            }

            {
                DataTable dt = DatasetGenerator.CreateNewBasicDataTable(new string[] { }, new Type[] { });

                using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt, new object[] { }))
                {
                    dr.Read();
                    SampleObject obj = new SampleObject();

                    Assert.ThrowsException <MissingFieldException>(() => { DbAutoFillHelper.FillObjectFromDataReader(dr, obj); });
                }
            }
        }
        public void DbResultsToBasicObject()
        {
            const string expectedStringValue = "String";
            const int    expectedIntValue    = 76;
            const string stringPropName      = "StringProperty";
            const string intPropName         = "IntField";

            DataTable dt = DatasetGenerator.CreateNewBasicDataTable(
                new string[] { stringPropName, intPropName },
                new Type[] { typeof(string), typeof(int) });

            using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt, expectedStringValue, expectedIntValue))
            {
                dr.Read();

                BasicObject obj = new BasicObject();
                DbAutoFillHelper.FillObjectFromDataReader(dr, obj);

                Assert.AreEqual(obj.StringProperty, expectedStringValue);
                Assert.AreEqual(obj.IntField, expectedIntValue);
            }
        }
        public void DbResultToComplexObject()
        {
            const string nameINField               = "NameIN";
            const string toDbUuidField             = "ToDbUuid";
            const string fromDbIdField             = "FromDbId";
            const string expectedAliasedColumnName = "ALittleTest";

            const string expectedNameINValue       = "ComplexObject";
            const int    unexpectedToDbUuidValue   = 23;
            const int    expectedFromDbUuid        = 3;
            const int    expectedToDbUuidValue     = -19;
            const bool   expectedAliaseColumnValue = true;

            DataTable dt = DatasetGenerator.CreateNewBasicDataTable(
                new string[] { nameINField, toDbUuidField, fromDbIdField, expectedAliasedColumnName },
                new Type[] { typeof(string), typeof(int), typeof(int), typeof(string) });

            using (IDataReader dr = DatasetGenerator.CreateBasicDataReader(dt,
                                                                           expectedNameINValue,
                                                                           unexpectedToDbUuidValue,
                                                                           expectedFromDbUuid,
                                                                           expectedAliaseColumnValue))
            {
                dr.Read();

                ComplexObject obj = new ComplexObject();
                obj.ToDbUuid = expectedToDbUuidValue;

                DbAutoFillHelper.FillObjectFromDataReader(dr, obj);

                Assert.AreEqual(expectedNameINValue, obj.NameIN);
                Assert.AreNotEqual(unexpectedToDbUuidValue, obj.ToDbUuid);
                Assert.AreEqual(expectedToDbUuidValue, obj.ToDbUuid);
                Assert.AreEqual(expectedFromDbUuid, obj.FromDbId);
                Assert.AreEqual(expectedAliaseColumnValue, obj.Aliased);
            }
        }