[Mono-dev] moq3 and ninject2 compatibility

Bas Smit basjsmit at gmail.com
Tue Mar 3 14:21:04 EST 2009


Hi guys,

Im working on moq3 and ninject2 compatibility. For moq3 there are currently
two bugs holding me back (one more failing test case, I'll get to that one
soon):

https://bugzilla.novell.com/show_bug.cgi?id=480819
https://bugzilla.novell.com/show_bug.cgi?id=480807

However with ninject its a bit trickier. It has has a bunch of tests to
check the dispose code (example below). For this purpose we need a way to
force disposing of unused objects. Currently the tests use GC.Collect() for
that, however on mono that doesnt necessarily mean that unused objects are
disposed of. Is there a way to force the GC to dispose of all unused
objects? Any thoughts?

Regards, Bas


Here is an example of such a (xunit) test:

[Fact]
public void InstancesActivatedWithinScopeA
reDeactivatedAfterThreadIsGarbageCollectedAndCacheIsPruned()
{
    kernel.Bind<NotifiesWhenDisposed>().ToSelf().InThreadScope();
    var cache = kernel.Components.Get<ICache>();

    NotifiesWhenDisposed instance = null;

    ThreadStart callback = () => instance =
kernel.Get<NotifiesWhenDisposed>();

    var thread = new Thread(callback);

    thread.Start();
    thread.Join();

    thread = null;

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

    cache.Prune();

    instance.ShouldNotBeNull();
    instance.IsDisposed.ShouldBeTrue();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090303/447f7a52/attachment.html 


More information about the Mono-devel-list mailing list