コード例 #1
0
        public void Compares_Compounds_With_Lesser_Amount_Of_Values()
        {
            var comp1 = new CompoundValue <int, int, int>(1, 1);
            var comp2 = new CompoundValue <int, int, int>(1, 1, 2);

            Assert.AreEqual(0, comp1.CompareTo(comp2));
            Assert.AreEqual(0, comp2.CompareTo(comp1));

            comp1 = new CompoundValue <int, int, int>(1, 1, -1);
            comp2 = new CompoundValue <int, int, int>(1, 1);
            Assert.AreEqual(0, comp1.CompareTo(comp2));
            Assert.AreEqual(0, comp2.CompareTo(comp1));

            comp1 = new CompoundValue <int, int, int>(1, 1);
            comp2 = new CompoundValue <int, int, int>(1, 1, -1);
            Assert.AreEqual(0, comp1.CompareTo(comp2));
            Assert.AreEqual(0, comp2.CompareTo(comp1));

            comp1 = new CompoundValue <int, int, int>(1, 2);
            comp2 = new CompoundValue <int, int, int>(1, -1, 0);
            Assert.AreEqual(1, comp1.CompareTo(comp2));
            Assert.AreEqual(-1, comp2.CompareTo(comp1));

            comp1 = new CompoundValue <int, int, int>(1, -1, 0);
            comp2 = new CompoundValue <int, int, int>(1, 2);
            Assert.AreEqual(-1, comp1.CompareTo(comp2));
            Assert.AreEqual(1, comp2.CompareTo(comp1));
        }
コード例 #2
0
        public void Treats_Nulls_As_Equal()
        {
            var comp1 = new CompoundValue <string, string>("1", null);
            var comp2 = new CompoundValue <string, string>("1", null);

            Assert.AreEqual(0, comp1.CompareTo(comp2));
            Assert.AreEqual(0, comp2.CompareTo(comp1));
        }
コード例 #3
0
        public void Compares_Ok_When_Equal()
        {
            var comp1 = new CompoundValue <int, int>(1, 1);
            var comp2 = new CompoundValue <int, int>(1, 1);

            Assert.AreEqual(0, comp1.CompareTo(comp2));
            Assert.AreEqual(0, comp2.CompareTo(comp1));
        }
コード例 #4
0
        public void Treats_Second_Null_As_Smallest_Value()
        {
            var comp1 = new CompoundValue <string, string>("1", null);
            var comp2 = new CompoundValue <string, string>("1", "1");

            Assert.AreEqual(-1, comp1.CompareTo(comp2));
            Assert.AreEqual(1, comp2.CompareTo(comp1));
        }
コード例 #5
0
        public void Compares_Ok_With_2_Params_On_Second_Param()
        {
            var comp1 = new CompoundValue <int, int>(1, 1);
            var comp2 = new CompoundValue <int, int>(2, 1);

            Assert.AreEqual(-1, comp1.CompareTo(comp2));
            Assert.AreEqual(1, comp2.CompareTo(comp1));
        }