Tortuga-TestMonkey
Tortuga-TestMonkey copied to clipboard
Memory Tests
foreach (var constructor in Class.Constructors.Where(c => c.IsCreatable))
{
<text>
@Tag("Memory")
@TestAttribute
public void @(Test.ClassName + "_Memory_" + constructor.SafeName)()
{
Func<WeakReference> ctr = () =>
{
try
{
return new WeakReference( @constructor.GetConstructorCode() );
}
catch (ArgumentException)
{
return null;
}
};
var wr = ctr();
if (wr == null)
return; //unable to create object, test aborted
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
//verify the object was collected
Assert.IsFalse(wr.IsAlive);
}
</text>
}