public void TestPublicNestedClassInternalNamedMethod() { Reset(); const int index = 99; _itemPublic = new PublicNestedTestClass(index); _reference = new WeakReference(_itemPublic); _action = _itemPublic.GetAction(WeakActionTestCase.InternalNamedMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(); Assert.AreEqual( PublicNestedTestClass.Expected + PublicNestedTestClass.Internal + index, PublicNestedTestClass.Result); _itemPublic = null; GC.Collect(); #if SILVERLIGHT Assert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed _action = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); #else Assert.IsFalse(_reference.IsAlive); #endif }
public void TestPublicNestedClassPublicNamedMethod() { Reset(); const int index = 99; _itemPublic = new PublicNestedTestClass(index); _action = _itemPublic.GetAction(WeakActionTestCase.PublicNamedMethod); _reference = new WeakReference(_itemPublic); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(); Assert.AreEqual( PublicNestedTestClass.Expected + PublicNestedTestClass.Public + index, PublicNestedTestClass.Result); _itemPublic = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); }
public void TestPublicClassPublicStaticMethod() { Reset(); const string parameter = "My parameter"; _itemPublic = new PublicNestedTestClass <string>(); _reference = new WeakReference(_itemPublic); _action = _itemPublic.GetAction(WeakActionTestCase.PublicStaticMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(parameter); Assert.AreEqual( PublicNestedTestClass <string> .Expected + PublicNestedTestClass <string> .PublicStatic + parameter, PublicNestedTestClass <string> .Result); _itemPublic = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); }
public void TestPublicClassAnonymousMethod() { Reset(); const int index = 99; const string parameter = "My parameter"; _itemPublic = new PublicNestedTestClass <string>(index); _reference = new WeakReference(_itemPublic); _action = _itemPublic.GetAction(WeakActionTestCase.AnonymousMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(parameter); Assert.AreEqual( PublicNestedTestClass <string> .Expected + index + parameter, PublicNestedTestClass <string> .Result); _itemPublic = null; GC.Collect(); #if SILVERLIGHT Assert.IsTrue(_reference.IsAlive); // Anonymous, private and internal methods cannot be GCed _action = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); #else Assert.IsFalse(_reference.IsAlive); #endif }
public void TestPublicNestedClassAnonymousStaticMethod() { Reset(); _itemPublic = new PublicNestedTestClass(); _reference = new WeakReference(_itemPublic); _action = _itemPublic.GetAction(WeakActionTestCase.AnonymousStaticMethod); Assert.IsTrue(_reference.IsAlive); Assert.IsTrue(_action.IsAlive); _action.Execute(); Assert.AreEqual( PublicNestedTestClass.Expected, PublicNestedTestClass.Result); _itemPublic = null; GC.Collect(); Assert.IsFalse(_reference.IsAlive); }