public void TestNull()
        {
            TestInt ti = new TestInt(1);
            object? o  = null;

            Assert.Greater(ti.CompareTo(o), 0);
        }
        public void TestSame()
        {
            TestInt ti = new TestInt(1);
            object  o  = ti;

            Assert.AreEqual(0, ti.CompareTo(o));
        }
        public void TestLessThan()
        {
            TestInt ti = new TestInt(1);
            object  o  = new TestInt(2);

            Assert.Less(ti.CompareTo(o), 0);
        }
        public void TestArgumentException()
        {
            TestInt ti = new TestInt(1);
            object  o  = "test";

            Assert.Throws <ArgumentException>(() => ti.CompareTo(o));
        }
Beispiel #5
0
        public void TestEqual()
        {
            var    ti = new TestInt(1);
            object o  = new TestInt(1);

            Assert.AreEqual(0, ti.CompareTo(o));
        }
        public void OperatorGreaterThan()
        {
            TestInt?iNull = null;
            TestInt i1    = new TestInt(1);
            TestInt i1b   = new TestInt(1);
            TestInt i2    = new TestInt(2);

            Assert.IsTrue(ComparableImpl.OperatorGreaterThan(i1, iNull));
            Assert.IsFalse(ComparableImpl.OperatorGreaterThan(iNull, i1));
            Assert.IsFalse(ComparableImpl.OperatorGreaterThan(i1, i1));
            Assert.IsFalse(ComparableImpl.OperatorGreaterThan(i1, i1b));
            Assert.IsFalse(ComparableImpl.OperatorGreaterThan(i1, i2));
            Assert.IsTrue(ComparableImpl.OperatorGreaterThan(i2, i1));
        }
Beispiel #7
0
        public void OperatorLessThanOrEqual()
        {
            TestInt?iNull = null;
            var     i1    = new TestInt(1);
            var     i1b   = new TestInt(1);
            var     i2    = new TestInt(2);

            Assert.IsTrue(ComparableImpl.OperatorLessThanOrEqual(iNull, i1));
            Assert.IsFalse(ComparableImpl.OperatorLessThanOrEqual(i1, iNull));
            Assert.IsTrue(ComparableImpl.OperatorLessThanOrEqual(i1, i1));
            Assert.IsTrue(ComparableImpl.OperatorLessThanOrEqual(i1, i1b));
            Assert.IsTrue(ComparableImpl.OperatorLessThanOrEqual(i1, i2));
            Assert.IsFalse(ComparableImpl.OperatorLessThanOrEqual(i2, i1));
        }