示例#1
0
        public void CopyFields_ExtendedDynamicRow_To_DynamicRow()
        {
            var schema    = Schema.GetForTypedDoc(typeof(Person));
            var fieldDefs = schema.FieldDefs.ToList();

            fieldDefs.Add(new Schema.FieldDef("Info", typeof(string), new QuerySource.ColumnDef("Info")));
            fieldDefs.Add(new Schema.FieldDef("Count", typeof(long), new QuerySource.ColumnDef("Info")));
            var extendedSchema = new Schema("sname", fieldDefs.ToArray());

            var from = new DynamicDoc(extendedSchema);

            from["FirstName"]  = "Ivan";
            from["Amount"]     = 10;
            from["DOB"]        = new DateTime(1990, 2, 16);
            from["GoodPerson"] = true;
            from["Info"]       = "extended info";
            from["Count"]      = long.MaxValue;

            var to = new DynamicDoc(schema);

            from.CopyFields(to);

            Aver.AreObjectsEqual(to["FirstName"], from["FirstName"]);
            Aver.AreObjectsEqual(to["Amount"], from["Amount"]);
            Aver.AreObjectsEqual(to["DOB"], from["DOB"]);
            Aver.AreObjectsEqual(to["GoodPerson"], from["GoodPerson"]);
        }
示例#2
0
        public void CopyFields_DynamicRow_To_Amorphous_IncludeAmorphous()
        {
            var schema = Schema.GetForTypedDoc(typeof(Person));
            var from   = new DynamicDoc(schema);

            from["FirstName"]  = "Ivan";
            from["Amount"]     = 10;
            from["DOB"]        = new DateTime(1990, 2, 16);
            from["GoodPerson"] = true;

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

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

            from.CopyFields(to, includeAmorphousData:  true);

            Aver.AreEqual(0, to.Schema.FieldCount);
            Aver.AreEqual(12, to.AmorphousData.Count);
            Aver.AreObjectsEqual(123, to.AmorphousData["field1"]);
            Aver.AreObjectsEqual(from["FirstName"], to.AmorphousData["FirstName"]);
            Aver.AreObjectsEqual(from["Amount"], to.AmorphousData["Amount"]);
            Aver.AreObjectsEqual(from["DOB"], to.AmorphousData["DOB"]);
            Aver.AreObjectsEqual(from["GoodPerson"], to.AmorphousData["GoodPerson"]);
        }
示例#3
0
        public void CopyFields_DynamicRow()
        {
            var from = new DynamicDoc(Schema.GetForTypedDoc(typeof(Person)));

            from["FirstName"]        = "Ivan";
            from["LastName"]         = "Petrov";
            from["Amount"]           = 10;
            from["Classification"]   = "class1";
            from["Description"]      = null;
            from["DOB"]              = new DateTime(1990, 2, 16);
            from["GoodPerson"]       = true;
            from["ID"]               = "abc";
            from["LuckRatio"]        = 12345.6789D;
            from["YearsInSpace"]     = 20;
            from["YearsWithCompany"] = null;

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

            to["Description"]      = "descr";
            to["YearsWithCompany"] = 30;

            from.CopyFields(to);

            Aver.AreObjectsEqual(to["FirstName"], from["FirstName"]);
            Aver.AreObjectsEqual(to["LastName"], from["LastName"]);
            Aver.AreObjectsEqual(to["Amount"], from["Amount"]);
            Aver.AreObjectsEqual(to["Classification"], from["Classification"]);
            Aver.AreObjectsEqual(to["Description"], from["Description"]);
            Aver.AreObjectsEqual(to["DOB"], from["DOB"]);
            Aver.AreObjectsEqual(to["GoodPerson"], from["GoodPerson"]);
            Aver.AreObjectsEqual(to["ID"], from["ID"]);
            Aver.AreObjectsEqual(to["LuckRatio"], from["LuckRatio"]);
            Aver.AreObjectsEqual(to["YearsInSpace"], from["YearsInSpace"]);
            Aver.AreObjectsEqual(to["YearsWithCompany"], from["YearsWithCompany"]);
        }