public void Test1() { Map.Extensions = TypeExtension.GetExtensions("Mapping.xml"); Enum1 e1 = (Enum1)Map.ValueToEnum("3", typeof(Enum1)); Assert.AreEqual(Enum1.Value2, e1); Enum2 e2 = (Enum2)Map.ValueToEnum("3", typeof(Enum2)); Assert.AreEqual(Enum2.Value2, e2); Enum3 e3 = (Enum3)Map.ValueToEnum("4", typeof(Enum3)); Assert.AreEqual(Enum3.Value2, e3); Enum4 e4 = (Enum4)Map.ValueToEnum("4", typeof(Enum4)); Assert.AreEqual(Enum4.Value2, e4); Dest o = (Dest)Map.ObjectToObject(new Source(), typeof(Dest)); Assert.AreEqual(Enum1.Value2, o.Field1); Assert.AreEqual(Enum1.Value1, o.Field2); Assert.AreEqual(Enum2.Value1, o.Field3); }
public void Test() { Map.Extensions = TypeExtension.GetExtensions("Map.xml"); Assert.AreEqual("AL", Map.EnumToValue(CountryCodeEnum.AL)); Assert.AreEqual(101, Map.EnumToValue(OtherEnum.EnumValue2)); }
public void Test4() { Map.Extensions = TypeExtension.GetExtensions("Map.xml"); StrDest2 sd = Map.ObjectToObject <StrDest2>(new Source(null)); Assert.IsNull(sd.Field); }
public void Test3() { Map.Extensions = TypeExtension.GetExtensions("Map.xml"); StrDest2 sd = Map.ObjectToObject <StrDest2>(new Source("AL")); Assert.AreEqual(Mapping.EnumExtension.CountryCodeEnum.AL, sd.Field); }
public void Test() { SqlQuery <MyPersonObject> query = new SqlQuery <MyPersonObject>(); /*[a]*/ query.Extensions = TypeExtension.GetExtensions("XmlExtension.xml") /*[/a]*/; MyPersonObject person = query.SelectByKey(1); Assert.IsNotNull(person); }
public void GenericsTest() { using (DbManager db = new DbManager()) { SqlQuery <Person1> sq = new SqlQuery <Person1>(db); sq.Extensions = TypeExtension.GetExtensions(@"XmlExtension.xml"); Assert.IsNotNull(sq.Extensions["Person1"]); Person1 ps = sq.SelectByKey(1); Assert.IsNotNull(ps); } }
public void Test() { using (DbManager db = new DbManager()) { SqlQuery sq = new SqlQuery(db); sq.Extensions = TypeExtension.GetExtensions(@"XmlExtension.xml"); Assert.IsNotNull(sq.Extensions["Person1"]); Person1 ps = (Person1)sq.SelectByKey(typeof(Person1), 1); Assert.IsNotNull(ps); } }
//[Test] public void ObjToDicTest() { var obj = new TestObj { Country = CountryCodeEnum1.DZ, Other = OtherEnum1.EnumValue2 }; var sh = new MappingSchema { Extensions = TypeExtension.GetExtensions("Map.xml") }; var pars = sh.MapObjectToDictionary(obj); Assert.AreEqual("DZ", pars["country_code"]); Assert.AreEqual(101, pars["other"]); }
public void MultiKeyRelationTest() { MappingSchema ms = new MappingSchema(); ms.Extensions = TypeExtension.GetExtensions("Mapping.xml"); bool isSet = false; List <MapRelationBase> relations = ms.MetadataProvider.GetRelations(ms, ms.Extensions, typeof(TestType), null, out isSet); Assert.IsTrue(isSet); Assert.AreEqual(1, relations.Count); Assert.AreEqual(2, relations[0].MasterIndex.Fields.Length); Assert.AreEqual(2, relations[0].SlaveIndex.Fields.Length); }
public void Test() { Map.Extensions = TypeExtension.GetExtensions("Mapping.xml"); object o = Map.Extensions["TriState"]["Yes"]["MapValue"].Value; Assert.AreEqual("yes", o); Source s = new Source(); Dest d = (Dest)Map.ObjectToObject(s, typeof(Dest)); Assert.AreEqual(TriState.No, d.Field1); Assert.AreEqual(1, d.Field2); Assert.AreEqual(2, d.Field3); Assert.AreEqual(54, d.Field4); Assert.AreEqual(TriState.NotApplicable, Map.ValueToEnum("1234", typeof(TriState))); }
public void Test() { Person p = (Person) new SqlQuery().SelectByKey(typeof(Person), 1); Assert.AreEqual(1, p.ID); Assert.AreEqual("John", p.FName); Assert.AreEqual("Pupkin", p.LName); MappingSchema map = new MappingSchema(); map.Extensions = TypeExtension.GetExtensions("XmlMap.xml"); DataRow dr = map.MapObjectToDataRow(p, new DataTable()); Assert.AreEqual(1, dr["PERSON_ID"]); Assert.AreEqual("John", dr["FIRST_NAME"]); Assert.AreEqual("Pupkin", dr["LAST_NAME"]); }