public void TestDictionaryComparison() { Variant v1 = new Variant(Variant.EnumType.Dictionary); v1.Add("key1", new Variant("value1")); v1.Add("key2", new Variant("value2")); Variant v2 = new Variant(Variant.EnumType.Dictionary); v2.Add("key2", new Variant("value2")); v2.Add("key1", new Variant("value1")); Variant v3 = new Variant(Variant.EnumType.Dictionary); v3.Add("key2", new Variant("value1")); v3.Add("key3", new Variant("value2")); Variant v4 = new Variant(Variant.EnumType.Dictionary); 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)); }
public void TestComparison() { Variant v1 = new Variant(new TestObject1("some value")); Variant v2 = new Variant(new TestObject1("some other value")); Variant v3 = new Variant(new TestObject2("some value")); 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)); }
public void TestComparison() { Variant v1 = new Variant(new byte[] { 0x01, 0x02, 0x03 }); Variant v2 = new Variant(new byte[] { 0x01, 0x02, 0x04 }); Variant v3 = new Variant(new byte[] { 0x01, 0x02, 0x03, 0x04 }); 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)); }
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)); }
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)); }
public void TestCompareTo() { var one = new Variant(1); var two = new Variant(2); var otherOne = new Variant((short)1); Assert.That(one, Is.Not.LessThan(one)); Assert.That(one, Is.LessThan(two)); Assert.That(one, Is.LessThanOrEqualTo(one)); Assert.That(one, Is.LessThanOrEqualTo(two)); Assert.That(one, Is.Not.GreaterThan(one)); Assert.That(one, Is.Not.GreaterThan(two)); Assert.That(one, Is.GreaterThanOrEqualTo(one)); Assert.That(one, Is.Not.GreaterThanOrEqualTo(two)); Assert.That(one < two, Is.True); Assert.That(one <= two, Is.True); Assert.That(one > two, Is.False); Assert.That(one >= two, Is.False); // types must match Assert.That(() => one.CompareTo(otherOne), Throws.InvalidOperationException); Utility.AssertNoGLibLog(); }
public void TestComparison() { TypedArray a1 = new TypedArray(Variant.EnumType.Double, 2); a1[0] = 1.0; a1[1] = 2.0; Variant v1 = new Variant(a1); TypedArray a2 = new TypedArray(Variant.EnumType.Double, 2); a2[0] = 1.0; a2[1] = 2.0; Variant v2 = new Variant(a2); TypedArray a3 = new TypedArray(Variant.EnumType.Double, 2); a3[0] = 2.0; a3[1] = 1.0; Variant v3 = new Variant(a3); 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)); }
public virtual int CompareTo(object obj) { if (obj is ObjectVariants) { var other = (ObjectVariants)obj; return(Variant.CompareTo(other.Variant)); } throw new ArgumentException(); }
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)); }
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)); }
public int CompareTo(FrameworkVersion other) { if (Version != other.Version) { return(Version.CompareTo(other.Version)); } if (ServicePack != other.ServicePack) { return(ServicePack.CompareTo(other.ServicePack)); } if (Variant != other.Variant) { return(Variant.CompareTo(other.Variant)); } return(0); }
int IComparable.CompareTo(object obj) { ItemVM bObj = (ItemVM)obj; if (this != bObj) { string a = DisplayName; string b = bObj.DisplayName; int result = a.CompareTo(b); if (0 == result && null != Variant && null != bObj.Variant) { result = Variant.CompareTo(bObj.Variant); } return(result); } return(0); }