コード例 #1
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);

            Assert.AreEqual(to.FirstName, from.FirstName);
            Assert.AreEqual(to.LastName, from.LastName);
            Assert.AreEqual(to.Amount, from.Amount);
            Assert.AreEqual(to.Classification, from.Classification);
            Assert.AreEqual(to.Description, from.Description);
            Assert.AreEqual(to.DOB, from.DOB);
            Assert.AreEqual(to.GoodPerson, from.GoodPerson);
            Assert.AreEqual(to.ID, from.ID);
            Assert.AreEqual(to.LuckRatio, from.LuckRatio);
            Assert.AreEqual(to.YearsInSpace, from.YearsInSpace);
            Assert.AreEqual(to.YearsWithCompany, from.YearsWithCompany);
        }
コード例 #2
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 AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Person)));

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

            from.CopyFields(to, true);

            Assert.AreEqual(11, to.Schema.FieldCount);
            Assert.AreEqual(6, to.AmorphousData.Count);
            Assert.AreEqual(123, to.AmorphousData["field1"]);
            Assert.AreEqual("John", to.AmorphousData["FirstName"]);
            Assert.AreEqual(from.Count, to.AmorphousData["Count"]);
            Assert.AreEqual(from.Info, to.AmorphousData["Info"]);
            Assert.AreEqual(null, to.AmorphousData["Parent"]);
            Assert.AreEqual(null, to.AmorphousData["Children"]);
            Assert.AreEqual(from.FirstName, to["FirstName"]);
            Assert.AreEqual(from.Amount, to["Amount"]);
            Assert.AreEqual(from.YearsWithCompany, to["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);

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