public void TestInternalClassAnonymousMethod() { Reset(); const int index = 99; _itemInternal = new InternalTestClass(index); _reference = new WeakReference(_itemInternal); _action = _itemInternal.GetAction(WeakActionTestCase.AnonymousMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(); Assert.AreEqual( InternalTestClass.Expected + index, InternalTestClass.Result); _itemInternal = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); }
public void TestPublicClassPublicStaticMethod() { Reset(); _itemPublic = new PublicTestClass(); _reference = new WeakReference(_itemPublic); _action = _itemPublic.GetAction(WeakActionTestCase.PublicStaticMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(); Assert.AreEqual( PublicTestClass.Expected + PublicTestClass.PublicStatic, PublicTestClass.Result); _itemPublic = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); }
public void TestPublicClassPrivateNamedMethod() { Reset(); const int index = 99; _itemPublic = new PublicTestClass(index); _reference = new WeakReference(_itemPublic); _action = _itemPublic.GetAction(WeakActionTestCase.PrivateNamedMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(); Assert.AreEqual( PublicTestClass.Expected + PublicTestClass.Private + index, PublicTestClass.Result); _itemPublic = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); }
public void TestInternalClassPublicStaticMethod() { Reset(); _itemInternal = new InternalTestClass(); _reference = new WeakReference(_itemInternal); _action = _itemInternal.GetAction(WeakActionTestCase.PublicStaticMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(); Assert.AreEqual( InternalTestClass.Expected + InternalTestClass.PublicStatic, InternalTestClass.Result); _itemInternal = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); }
public void TestPrivateNestedClassPrivateStaticMethod() { Reset(); _itemPrivate = new PrivateNestedTestClass(); _reference = new WeakReference(_itemPrivate); _action = _itemPrivate.GetAction(WeakActionTestCase.PrivateStaticMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(); Assert.AreEqual( PrivateNestedTestClass.Expected + PrivateNestedTestClass.PrivateStatic, PrivateNestedTestClass.Result); _itemPrivate = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); }
public void TestPrivateNestedClassInternalNamedMethod() { Reset(); const int index = 99; _itemPrivate = new PrivateNestedTestClass(index); _reference = new WeakReference(_itemPrivate); _action = _itemPrivate.GetAction(WeakActionTestCase.InternalNamedMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(); Assert.AreEqual( PrivateNestedTestClass.Expected + PrivateNestedTestClass.Internal + index, PrivateNestedTestClass.Result); _itemPrivate = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); }