Ejemplo n.º 1
0
        public void TestListComparison()
        {
            Variant v1 = new Variant(Variant.EnumType.List);
            v1.Add(new Variant("value1"));
            v1.Add(new Variant("value2"));

            Variant v2 = new Variant(Variant.EnumType.List);
            v2.Add(new Variant("value2"));
            v2.Add(new Variant("value1"));

            Assert.AreEqual(0, v1.CompareTo(v1));
            Assert.AreEqual(-1, v1.CompareTo(v2));
            Assert.AreEqual(1, v2.CompareTo(v1));
        }
Ejemplo n.º 2
0
        public void TestTSComparison()
        {
            Variant v1 = new Variant(Variant.EnumType.TimeSeries);
            v1.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1"));
            v1.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value2"));

            Variant v2 = new Variant(Variant.EnumType.TimeSeries);
            v2.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value1"));
            v2.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2"));

            Variant v3 = new Variant(Variant.EnumType.TimeSeries);
            v3.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2"));
            v3.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value1"));

            Assert.AreEqual(0, v1.CompareTo(v1));
            Assert.AreEqual(-1, v1.CompareTo(v2));
            Assert.AreEqual(1, v2.CompareTo(v1));
            Assert.AreEqual(-1, v1.CompareTo(v3));
            Assert.AreEqual(1, v3.CompareTo(v1));
        }
Ejemplo n.º 3
0
        public void TestBagComparison()
        {
            Variant v1 = new Variant(Variant.EnumType.Bag);
            v1.Add("key1", new Variant("value1"));
            v1.Add("key2", new Variant("value2"));

            Variant v2 = new Variant(Variant.EnumType.Bag);
            v2.Add("key1", new Variant("value1"));
            v2.Add("key2", new Variant("value2"));

            Variant v3 = new Variant(Variant.EnumType.Bag);
            v3.Add("key2", new Variant("value1"));
            v3.Add("key3", new Variant("value2"));

            Variant v4 = new Variant(Variant.EnumType.Bag);
            v4.Add("key1", new Variant("value2"));
            v4.Add("key2", new Variant("value3"));

            Assert.AreEqual(0, v1.CompareTo(v2));
            Assert.AreEqual(-1, v1.CompareTo(v3));
            Assert.AreEqual(1, v3.CompareTo(v1));
            Assert.AreEqual(-1, v1.CompareTo(v4));
            Assert.AreEqual(1, v4.CompareTo(v1));
        }
Ejemplo n.º 4
0
        public void TestComparison()
        {
            System.Data.DataTable dt1 = new DataTable();
            dt1.Columns.Add(new DataColumn("Double", typeof(double)));
            dt1.Columns.Add(new DataColumn("String", typeof(string)));

            DataRow dr1 = dt1.NewRow();
            dr1[0] = 1.0;
            dr1[1] = "value";

            dt1.Rows.Add(dr1);

            Variant v1 = new Variant(dt1);

            System.Data.DataTable dt2 = new DataTable();
            dt2.Columns.Add(new DataColumn("Double", typeof(double)));
            dt2.Columns.Add(new DataColumn("String", typeof(string)));

            DataRow dr2 = dt2.NewRow();
            dr2[0] = 1.0;
            dr2[1] = "value";

            dt2.Rows.Add(dr2);

            Variant v2 = new Variant(dt2);

            System.Data.DataTable dt3 = new DataTable();
            dt3.Columns.Add(new DataColumn("Double", typeof(double)));
            dt3.Columns.Add(new DataColumn("String", typeof(string)));

            DataRow dr3 = dt3.NewRow();
            dr3[0] = 2.0;
            dr3[1] = "value";

            dt3.Rows.Add(dr3);

            Variant v3 = new Variant(dt3);

            Assert.IsTrue(v1.Equals(v2));
            Assert.IsFalse(v1.Equals(v3));

            Assert.AreEqual(0, v1.CompareTo(v2));
            Assert.AreEqual(-1, v2.CompareTo(v3));
            Assert.AreEqual(1, v3.CompareTo(v2));
        }
Ejemplo n.º 5
0
        public void TestTupleComparison()
        {
            Variant v1 = new Variant(Variant.EnumType.Tuple, 2);
            v1[0] = new Variant("value1");
            v1[1] = new Variant("value2");

            Variant v2 = new Variant(Variant.EnumType.Tuple, 2);
            v2[0] = new Variant("value2");
            v2[1] = new Variant("value1");

            Assert.AreEqual(0, v1.CompareTo(v1));
            Assert.AreEqual(-1, v1.CompareTo(v2));
            Assert.AreEqual(1, v2.CompareTo(v1));
        }