Beispiel #1
0
        public void Equals_EquatableWeakReference_Are_Reference_Equal()
        {
            // Arrange
            var target = new RevokeNotifierTestClass();
            var wr1    = new EquatableWeakReference <RevokeNotifierTestClass>(target);
            var wr2    = new EquatableWeakReference <RevokeNotifierTestClass>(target);

            // Act
            var result = wr1.Equals(wr2);

            // Assert
            Assert.True(result);
        }
Beispiel #2
0
        public void Equals_EquatableWeakReference_Are_Not_Equal_Even_If_HashCode_is_And_Target_collected()
        {
            // Arrange
            var wr     = CreateEquatableWeakReference(true);
            var target = new RevokeNotifierTestClass();
            var wr2    = new EquatableWeakReference <RevokeNotifierTestClass>(target);

            // Act
            var result1 = wr2.Equals(wr);

            // Assert
            Assert.Null(wr.Target);
            Assert.AreEqual(wr.GetHashCode(), wr2.GetHashCode());
            Assert.AreNotEqual(wr, wr2);
        }