public void ModelToModel_正常情況() { var result = source.Map <TargetModel, SourceModel>(); Assert.AreEqual(source.DecimalProp, result.DecimalProp); Assert.AreEqual(source.DoubleProp, result.DoubleProp); Assert.AreEqual(source.IntegerProp, result.IntegerProp); Assert.AreEqual(source.LongProp, result.LongProp); Assert.AreEqual(source.BooleanProp, result.BooleanProp); Assert.AreEqual(source.StringProp, result.StringProp); Assert.AreEqual(source.DateTimeProp, result.DateTimeProp); }
public void ModelToModel() { //Old Way var targetOld = new TargetModel(); targetOld.StringProp = _source.StringProp; targetOld.DecimalProp = _source.DecimalProp; targetOld.DoubleProp = _source.DoubleProp; targetOld.IntegerProp = _source.IntegerProp; targetOld.LongProp = _source.LongProp; targetOld.BooleanProp = _source.BooleanProp; targetOld.DateTimeProp = _source.DateTimeProp; //New Way var targetNew = _source.Map <TargetModel, SourceModel>(); //Result Assert.AreEqual(targetOld.StringProp, targetNew.StringProp); Assert.AreEqual(targetOld.DecimalProp, targetNew.DecimalProp); Assert.AreEqual(targetOld.DoubleProp, targetNew.DoubleProp); Assert.AreEqual(targetOld.IntegerProp, targetNew.IntegerProp); Assert.AreEqual(targetOld.LongProp, targetNew.LongProp); Assert.AreEqual(targetOld.BooleanProp, targetNew.BooleanProp); Assert.AreEqual(targetOld.DateTimeProp, targetNew.DateTimeProp); }
public void ModelToModel_來源是Null() { SourceModel nullSource = null; nullSource.Map <TargetModel, SourceModel>(); }