示例#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
        public void TestRoundTripSqlGuid()
        {
            DbGuid testA  = DbGuid.NewGuid();
            DbGuid dbtest = testA.ToSqlGuid();

            Assert.AreEqual(dbtest, testA);
            Assert.AreEqual(dbtest.GetHashCode(), testA.GetHashCode());
            Assert.AreEqual(0, dbtest.CompareTo(testA));
            DbGuid testB = dbtest.ToSequenceGuid();

            Assert.AreEqual(testA, testB);
        }
示例#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;
            }
        }