private static void Verify(GoalPlanningModel1 obj, TypeModel model, string caption) { var clone = (GoalPlanningModel1)model.DeepClone(obj); Assert.Null(clone.PublishedGoals); //, caption + ":published"); Assert.NotNull(clone.ProposedGoals); //, caption + ":proposed"); Assert.Single(clone.ProposedGoals); //, caption + ":count"); Assert.Equal(23, clone.ProposedGoals.Single().X); //, caption + ":X"); }
public void TestPlanningModelWithEnumerables() { var obj = new GoalPlanningModel1 { ProposedGoals = new List <ProposedGoal> { new ProposedGoal { X = 23 } } }; var model = RuntimeTypeModel.Create(); model.AutoCompile = false; Verify(obj, model, "Runtime"); model.CompileInPlace(); Verify(obj, model, "CompileInPlace"); Verify(obj, model.Compile(), "Compile"); var dll = model.Compile("TestPlanningModelWithEnumerables", "TestPlanningModelWithEnumerables.dll"); Verify(obj, dll, "dll"); PEVerify.AssertValid("TestPlanningModelWithEnumerables.dll"); }
private static void Verify(GoalPlanningModel1 obj, TypeModel model, string caption) { var clone = (GoalPlanningModel1)model.DeepClone(obj); Assert.IsNull(clone.PublishedGoals, caption + ":published"); Assert.IsNotNull(clone.ProposedGoals, caption + ":proposed"); Assert.AreEqual(1, clone.ProposedGoals.Count(), caption + ":count"); Assert.AreEqual(23, clone.ProposedGoals.Single().X, caption + ":X"); }
public void TestPlanningModelWithEnumerables() { var obj = new GoalPlanningModel1 { ProposedGoals = new List<ProposedGoal> { new ProposedGoal { X = 23 } } }; var model = RuntimeTypeModel.Create(); model.AutoCompile = false; Verify(obj, model, "Runtime"); model.CompileInPlace(); Verify(obj, model, "CompileInPlace"); Verify(obj, model.Compile(), "Compile"); var dll = model.Compile("TestPlanningModelWithEnumerables", "TestPlanningModelWithEnumerables.dll"); Verify(obj, dll, "dll"); PEVerify.AssertValid("TestPlanningModelWithEnumerables.dll"); }