public void PopulateExternalModel() { var random = new Random(); var intProp = random.Next(); var doubleProp = random.NextDouble(); var source = InternalModelA.Create(intProp, doubleProp); var target = source.PopulateExternalModel <InternalModelA, ExternalModelA>(); Assert.Equal(target.StringProp, source.StringProp); Assert.Equal(target.IntProp, source.IntProp); Assert.Equal(target.DoubleProp, source.DoubleProp); Assert.Equal(target.StringDict, source.StringDict); Assert.Equal(target.ModelB.StringProp, source.ModelB.StringProp); Assert.Equal(target.ModelB.IntProp, source.ModelB.IntProp); Assert.Equal(target.ModelB.DoubleProp, source.ModelB.DoubleProp); foreach (var model in source.ModelBList) { Assert.Contains(target.ModelBList, m => m.StringProp == model.StringProp && m.IntProp == model.IntProp && m.DoubleProp == model.DoubleProp); } }
public void PopulateFromExternalModel() { var random = new Random(); var sourceIntProp = random.Next(); var sourceDoubleProp = random.NextDouble(); var targetIntProp = random.Next(); var targetDoubleProp = random.NextDouble(); var source = ExternalModelA.Create(sourceIntProp, sourceDoubleProp); var target = InternalModelA.Create(targetIntProp, targetDoubleProp); target.PopulateFromExternalModel(source); Assert.Equal(target.StringProp, source.StringProp); Assert.Equal(target.IntProp, source.IntProp); Assert.Equal(target.DoubleProp, source.DoubleProp); Assert.Equal(target.StringPropExtra, "Another String"); Assert.Equal(target.IntPropExtra, targetIntProp); Assert.Equal(target.DoublePropExtra, targetDoubleProp); Assert.Equal(target.StringDict, source.StringDict); Assert.Equal(target.ModelB.StringProp, source.ModelB.StringProp); Assert.Equal(target.ModelB.IntProp, source.ModelB.IntProp); Assert.Equal(target.ModelB.DoubleProp, source.ModelB.DoubleProp); Assert.Equal(target.ModelB.StringPropExtra, "Another String"); Assert.Equal(target.ModelB.IntPropExtra, targetIntProp); Assert.Equal(target.ModelB.DoublePropExtra, targetDoubleProp); foreach (var model in source.ModelBList) { Assert.Contains(target.ModelBList, m => m.StringProp == model.StringProp && m.IntProp == model.IntProp && m.DoubleProp == model.DoubleProp); // && m.StringPropExtra == "Another String" // && m.IntPropExtra == targetIntProp // && m.DoublePropExtra == targetDoubleProp); } }