private static void Verify(GoalPlanningModel2 obj, TypeModel model, string caption)
        {
            var clone = (GoalPlanningModel2)model.DeepClone(obj);

            Assert.Null(clone.PublishedGoals);          //, caption + ":published");
            Assert.NotNull(clone.ProposedGoals);        //, caption + ":proposed");
            Assert.Equal(1, clone.ProposedGoals.Count); //, caption + ":count");
            Assert.Equal(23, clone.ProposedGoals[0].X); //, caption + ":X");
        }
        public void TestPlanningModelWithLists()
        {
            var obj = new GoalPlanningModel2
            {
                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("TestPlanningModelWithLists", "TestPlanningModelWithLists.dll");

            Verify(obj, dll, "dll");
            PEVerify.AssertValid("TestPlanningModelWithLists.dll");
        }
 private static void Verify(GoalPlanningModel2 obj, TypeModel model, string caption)
 {
     var clone = (GoalPlanningModel2)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[0].X, caption + ":X");
 }
 public void TestPlanningModelWithLists()
 {
     var obj = new GoalPlanningModel2
     {
         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("TestPlanningModelWithLists", "TestPlanningModelWithLists.dll");
     Verify(obj, dll, "dll");
     PEVerify.AssertValid("TestPlanningModelWithLists.dll");
 }