예제 #1
0
        public void CopyFields_ExtendedTypedRow_To_Amorphous_IncludeAmorphous()
        {
            var from = new ExtendedPerson
            {
                FirstName        = "Ivan",
                Amount           = 10,
                YearsWithCompany = null,
                Count            = 4567,
                Info             = "extended info"
            };

            var to = new AmorphousDynamicDoc(Schema.GetForTypedDoc(typeof(Person)));

            to.AmorphousData["field1"]    = 123;
            to.AmorphousData["FirstName"] = "John";

            from.CopyFields(to, includeAmorphousData: true);

            Aver.AreEqual(11, to.Schema.FieldCount);
            Aver.AreEqual(6, to.AmorphousData.Count);
            Aver.AreObjectsEqual(123, to.AmorphousData["field1"]);
            Aver.AreObjectsEqual("John", to.AmorphousData["FirstName"]);
            Aver.AreObjectsEqual(from.Count, to.AmorphousData["Count"]);
            Aver.AreObjectsEqual(from.Info, to.AmorphousData["Info"]);
            Aver.AreObjectsEqual(null, to.AmorphousData["Parent"]);
            Aver.AreObjectsEqual(null, to.AmorphousData["Children"]);
            Aver.AreObjectsEqual(from.FirstName, to["FirstName"]);
            Aver.AreObjectsEqual(from.Amount, to["Amount"]);
            Aver.AreObjectsEqual(from.YearsWithCompany, to["YearsWithCompany"]);
        }
예제 #2
0
        public void CopyFields_Extended_To_TypedRow()
        {
            var from = new ExtendedPerson
            {
                FirstName        = "John",
                Description      = "descr",
                YearsWithCompany = 30,
                Info             = "extended info",
                Count            = long.MaxValue
            };

            var to = new Person
            {
                FirstName        = "Ivan",
                Amount           = 10,
                DOB              = new DateTime(1990, 2, 16),
                YearsWithCompany = null
            };

            from.CopyFields(to);

            Aver.AreEqual(to.FirstName, from.FirstName);
            Aver.AreEqual(to.LastName, from.LastName);
            Aver.AreEqual(to.Amount, from.Amount);
            Aver.AreEqual(to.Classification, from.Classification);
            Aver.AreEqual(to.Description, from.Description);
            Aver.AreEqual(to.DOB, from.DOB);
            Aver.AreEqual(to.GoodPerson, from.GoodPerson);
            Aver.AreEqual(to.ID, from.ID);
            Aver.AreEqual(to.LuckRatio, from.LuckRatio);
            Aver.AreEqual(to.YearsInSpace, from.YearsInSpace);
            Aver.AreEqual(to.YearsWithCompany, from.YearsWithCompany);
        }
예제 #3
0
        public void CopyFields_TypedRow_Complex()
        {
            var from = new ExtendedPerson
            {
                FirstName = "Ivan",
                Parent    = new Person {
                    FirstName = "John", Amount = 12, GoodPerson = true
                },
                Children = new List <Person> {
                    new Person {
                        FirstName = "John"
                    }, new Person {
                        LuckRatio = 12.3D
                    }
                }
            };

            var to = new ExtendedPerson
            {
                FirstName        = "Anna",
                Description      = "descr",
                YearsWithCompany = 30,
                Parent           = new Person {
                    FirstName = "Maria"
                }
            };

            from.CopyFields(to);

            Aver.AreEqual(to.FirstName, from.FirstName);
            Aver.AreEqual(to.LastName, from.LastName);
            Aver.AreEqual(to.Amount, from.Amount);
            Aver.AreEqual(to.Classification, from.Classification);
            Aver.AreEqual(to.Description, from.Description);
            Aver.AreEqual(to.DOB, from.DOB);
            Aver.AreEqual(to.GoodPerson, from.GoodPerson);
            Aver.AreEqual(to.ID, from.ID);
            Aver.AreEqual(to.LuckRatio, from.LuckRatio);
            Aver.AreEqual(to.YearsInSpace, from.YearsInSpace);
            Aver.AreEqual(to.YearsWithCompany, from.YearsWithCompany);
            Aver.AreEqual(to.Info, from.Info);
            Aver.AreObjectsEqual(to.Parent, from.Parent);
            Aver.AreObjectsEqual(to.Children, from.Children);
        }