예제 #1
0
        private void TestEquality(DbGuid testA, DbGuid testB, bool expect)
        {
            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(expect, testA.GetHashCode() == testB.GetHashCode());
                Assert.AreEqual(expect, DbGuid.Comparer.GetHashCode(testA) == DbGuid.Comparer.GetHashCode(testB));

                Assert.AreEqual(expect, testA == testB);
                Assert.AreEqual(!expect, testA != testB);

                Assert.AreEqual(expect, ((object)testA).Equals(testB));
                Assert.AreEqual(expect, ((IEquatable <DbGuid>)testA).Equals(testB));

                Assert.AreEqual(expect, ((IComparable)testA).CompareTo(testB) == 0);
                Assert.AreEqual(expect, ((IComparable <DbGuid>)testA).CompareTo(testB) == 0);

                Assert.AreEqual(expect, DbGuid.Comparer.Equals(testA, testB));
                Assert.AreEqual(expect, DbGuid.Comparer.Compare(testA, testB) == 0);

                Assert.AreEqual(expect, testA.ToString() == testB.ToString());
                Assert.AreEqual(expect, testA.ToString("N") == testB.ToString("N"));
                Assert.AreEqual(expect, testA.ToString("N", null) == testB.ToString("N", null));

                //swap and try again
                DbGuid tmp = testA;
                testA = testB;
                testB = tmp;
            }
        }
예제 #2
0
        private void TestSequence(DbGuid small, DbGuid big)
        {
            Assert.IsTrue(small != big);
            Assert.IsTrue(big != small);

            Assert.IsTrue(small < big);
            Assert.IsTrue(big > small);

            Assert.IsTrue(small <= big);
            Assert.IsTrue(big >= small);

            Assert.IsFalse(small == big);
            Assert.IsFalse(big == small);

            Assert.IsFalse(big < small);
            Assert.IsFalse(small > big);

            Assert.IsFalse(big <= small);
            Assert.IsFalse(small >= big);

            Assert.IsTrue(small.CompareTo(big) < 0);
            Assert.IsTrue(big.CompareTo(small) > 0);

            Assert.IsTrue(DbGuid.Comparer.Compare(small, big) < 0);
            Assert.IsTrue(DbGuid.Comparer.Compare(big, small) > 0);

            Assert.IsTrue(small.ToString().CompareTo(big.ToString()) < 0);
        }
예제 #3
0
        private void TestEquality(DbGuid testA, DbGuid testB, bool expect)
        {
            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(expect, testA.GetHashCode() == testB.GetHashCode());
                Assert.AreEqual(expect, DbGuid.Comparer.GetHashCode(testA) == DbGuid.Comparer.GetHashCode(testB));

                Assert.AreEqual(expect, testA == testB);
                Assert.AreEqual(!expect, testA != testB);

                Assert.AreEqual(expect, ((object) testA).Equals(testB));
                Assert.AreEqual(expect, ((IEquatable<DbGuid>) testA).Equals(testB));

                Assert.AreEqual(expect, ((IComparable)testA).CompareTo(testB) == 0);
                Assert.AreEqual(expect, ((IComparable<DbGuid>)testA).CompareTo(testB) == 0);

                Assert.AreEqual(expect, DbGuid.Comparer.Equals(testA, testB));
                Assert.AreEqual(expect, DbGuid.Comparer.Compare(testA, testB) == 0);

                Assert.AreEqual(expect, testA.ToString() == testB.ToString());
                Assert.AreEqual(expect, testA.ToString("N") == testB.ToString("N"));
                Assert.AreEqual(expect, testA.ToString("N", null) == testB.ToString("N", null));

                //swap and try again
                DbGuid tmp = testA;
                testA = testB;
                testB = tmp;
            }
        }
예제 #4
0
        private void TestSequence(DbGuid small, DbGuid big)
        {
            Assert.IsTrue(small != big);
            Assert.IsTrue(big != small);

            Assert.IsTrue(small < big);
            Assert.IsTrue(big > small);

            Assert.IsTrue(small <= big);
            Assert.IsTrue(big >= small);

            Assert.IsFalse(small == big);
            Assert.IsFalse(big == small);

            Assert.IsFalse(big < small);
            Assert.IsFalse(small > big);
            
            Assert.IsFalse(big <= small);
            Assert.IsFalse(small >= big);
            
            Assert.IsTrue(small.CompareTo(big) < 0);
            Assert.IsTrue(big.CompareTo(small) > 0);

            Assert.IsTrue(DbGuid.Comparer.Compare(small, big) < 0);
            Assert.IsTrue(DbGuid.Comparer.Compare(big, small) > 0);
            
            Assert.IsTrue(small.ToString().CompareTo(big.ToString()) < 0);
        }