Esempio n. 1
0
        public void ConvertTest()
        {
            ModelClass model = new ModelClass()
            {
                id         = "234234234sdfsdfsdfsdfsdfsdf",
                number     = "23",
                Name       = "allen",
                IsRight    = "true",
                IsWrong    = "false",
                Date       = "2017-09-09",
                CreateDate = "2017-12-12",
                childs     = new List <ModelClassChild>()
                {
                    new ModelClassChild()
                    {
                        id        = "1111",
                        childname = "child1"
                    },
                    new ModelClassChild()
                    {
                        id        = "2222",
                        childname = "child2"
                    }
                }
            };

            var convertSuccess = true;

            try
            {
                EntityClass entity = new EntityClass();
                entity = ObjectConvert.Convert <ModelClass, EntityClass>(model);


                ModelClass cM = ObjectConvert.Convert <EntityClass, ModelClass>(entity);
            }
            catch (Exception e)
            {
                convertSuccess = false;
            }


            Assert.IsTrue(convertSuccess);
        }