Exemple #1
0
        public void CopyFields_AmorphousDynamicRow_IncludeAmorphous()
        {
            var from = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Empty)));
            from.AmorphousData["field1"] = "some data";
            from.AmorphousData["field2"] = 123;

            var to = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Empty)));
            to.AmorphousData["field2"] = "234";
            to.AmorphousData["field3"] = 1.2D;

            from.CopyFields(to, true);

            Assert.AreEqual(3, to.AmorphousData.Count);
            Assert.AreEqual(from.AmorphousData["field1"], to.AmorphousData["field1"]);
            Assert.AreEqual(from.AmorphousData["field2"], to.AmorphousData["field2"]);
            Assert.AreEqual(1.2D, to.AmorphousData["field3"]);
        }
Exemple #2
0
        public void CopyFields_AmorphousDynamicRow_NotIncludeAmorphous()
        {
            var from = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Person)));
            from["FirstName"] = "Ivan";
            from["LuckRatio"] = 12345.6789D;
            from.AmorphousData["field1"] = "some data";

            var to = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Person)));
            from["FirstName"] = "Jack";
            from["YearsInSpace"] = 20;

            from.CopyFields(to, false);

            Assert.AreEqual(to["FirstName"], from["FirstName"]);
            Assert.AreEqual(to["LuckRatio"], from["LuckRatio"]);
            Assert.AreEqual(to["YearsInSpace"], from["YearsInSpace"]);
            Assert.AreEqual(null, to.Schema["field1"]);
            Assert.AreEqual(0, to.AmorphousData.Count);
        }
Exemple #3
0
        public void CopyFields_AmorphousDynamicRow_Filter()
        {
            var from = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Empty)));
            from.AmorphousData["field1"] = "some data";
            from.AmorphousData["field2"] = 123;
            from.AmorphousData["field3"] = "info";

            var to = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Empty)));
            to.AmorphousData["field2"] = "234";
            to.AmorphousData["field3"] = 1.2D;
            to.AmorphousData["field4"] = 12345;

            from.CopyFields(to, true, false, null, (s, n) => n != "field2" );

            Assert.AreEqual(4, to.AmorphousData.Count);
            Assert.AreEqual(from.AmorphousData["field1"], to.AmorphousData["field1"]);
            Assert.AreEqual("234", to.AmorphousData["field2"]);
            Assert.AreEqual(to.AmorphousData["field3"], to.AmorphousData["field3"]);
            Assert.AreEqual(12345, to.AmorphousData["field4"]);
        }
Exemple #4
0
        public void ToAmorphousDynamicRow_FromString()
        {
            var str = @"{name: ""Orlov"", dob: ""02/12/2007 6:45 PM"", certified: true, serviceyears: 12, salary: 145000, extra: -1, yes: true}";

              var row = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(MySimpleData)));

              JSONReader.ToRow(row, str.JSONToDataObject() as JSONDataMap);

              Assert.AreEqual("Orlov", row["Name"]);
              Assert.AreEqual(new DateTime(2007, 2, 12, 18, 45, 0), row["DOB"]);
              Assert.AreEqual(true, row["Certified"]);
              Assert.AreEqual(12, row["ServiceYears"]);
              Assert.AreEqual(145000m, row["Salary"]);
              Assert.AreEqual(2, row.AmorphousData.Count);
              Assert.AreEqual(-1, row.AmorphousData["extra"]);
              Assert.AreEqual(true, row.AmorphousData["yes"]);
        }
Exemple #5
0
        public void CopyFields_AmorphousDynamicRow_To_DynamicRow()
        {
            var from = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Person)));
            from["FirstName"] = "Ivan";
            from["LuckRatio"] = 12345.6789D;
            from.AmorphousData["field1"] = "some data";

            var to = new DynamicRow(Schema.GetForTypedRow(typeof(Person)));
            to["Description"] = "descr";
            to["YearsWithCompany"] = 30;

            from.CopyFields(to);

            Assert.AreEqual(to["FirstName"], from["FirstName"]);
            Assert.AreEqual(to["LuckRatio"], from["LuckRatio"]);
            Assert.AreEqual(to["Description"], from["Description"]);
            Assert.AreEqual(to["YearsWithCompany"], from["YearsWithCompany"]);
            Assert.AreEqual(null, to.Schema["field1"]);
        }
Exemple #6
0
        public void CopyFields_TypedRow_To_Amorphous_NotIncludeAmorphous()
        {
            var from = new Person
            {
                FirstName = "Ivan",
                LastName = "Petrov",
                Amount = 10,
                Classification = "class1",
                YearsWithCompany = null
            };

            var to = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Empty)));
            to.AmorphousData["field1"] = 123;
            to.AmorphousData["FirstName"] = "John";

            from.CopyFields(to, false);

            Assert.AreEqual(0, to.Schema.FieldCount);
            Assert.AreEqual(2, to.AmorphousData.Count);
            Assert.AreEqual(123, to.AmorphousData["field1"]);
            Assert.AreEqual("John", to.AmorphousData["FirstName"]);
        }
Exemple #7
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"]);
        }
Exemple #8
0
        public void CopyFields_DynamicRow_To_Amorphous_NotIncludeAmorphous()
        {
            var schema = Schema.GetForTypedRow(typeof(Person));
            var from = new DynamicRow(schema);
            from["FirstName"] = "Ivan";
            from["Amount"] = 10;
            from["DOB"] = new DateTime(1990, 2, 16);
            from["GoodPerson"] = true;

            var to = new AmorphousDynamicRow(Schema.GetForTypedRow(typeof(Empty)));
            to.AmorphousData["field1"] = 123;
            to.AmorphousData["FirstName"] = "John";

            from.CopyFields(to, false);

            Assert.AreEqual(0, to.Schema.FieldCount);
            Assert.AreEqual(2, to.AmorphousData.Count);
            Assert.AreEqual(123, to.AmorphousData["field1"]);
            Assert.AreEqual("John", to.AmorphousData["FirstName"]);
        }