Exemplo n.º 1
0
        public void TestEquality()
        {
            // Initialize
            InstanceHandle handle      = 1;
            InstanceHandle equalHandle = 1;

            // Test with null parameter
            bool result = handle.Equals(null);

            Assert.IsFalse(result);

            // Test with other object type
            result = handle.Equals("string");
            Assert.IsFalse(result);

            // Test true
            Assert.IsTrue(handle.Equals(equalHandle));
            Assert.IsTrue(handle.Equals(1));
            Assert.IsTrue(handle == equalHandle);
            Assert.IsTrue(handle != InstanceHandle.HandleNil);

            // Test false
            Assert.IsFalse(handle.Equals(InstanceHandle.HandleNil));
            Assert.IsFalse(handle.Equals(0));
            Assert.IsFalse(handle != equalHandle);
            Assert.IsFalse(handle == InstanceHandle.HandleNil);

            // Test GetHashCode
            Assert.AreEqual(1, handle.GetHashCode());
        }