GetHashCode() public method

public GetHashCode ( ) : int
return int
        public void WeakReferenceGetsFreedButHashCodeRemainsConstant() {
            var obj = new object();
            var wrap = new WeakReferenceWrapper(obj);
            int hashcode = wrap.GetHashCode();

            obj = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            wrap.IsAlive.Should().Be.False();
            wrap.Target.Should().Be.Null();
            wrap.GetHashCode().Should().Be(hashcode);
        }
Example #2
0
        public void WeakReferenceGetsFreedButHashCodeRemainsConstant()
        {
            var obj      = new object();
            var wrap     = new WeakReferenceWrapper(obj);
            int hashcode = wrap.GetHashCode();

            obj = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();

            wrap.IsAlive.Should().Be.False();
            wrap.Target.Should().Be.Null();
            wrap.GetHashCode().Should().Be(hashcode);
        }