Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed test with weak reference in .NET 4.6.x #138

Merged
merged 1 commit into from
Jun 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Castle.Windsor.Tests/Lifestyle/ScopedLifestyleTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,22 @@ public void Transient_depending_on_scoped_component_is_not_tracked_by_the_contai

using (Container.BeginScope())
{
var udf = Container.Resolve<UsesDisposableFoo>();
var weakUdt = new WeakReference(udf);
udf = null;
var weakUdt = GetWeakReferenceToDisposableFoo();
GC.Collect();
Assert.IsFalse(weakUdt.IsAlive);
}
}

// method is needed because since 4.6.x under debug configuration local variables are not
// considered for garbage collection; hence if method is inlined - test will fail
private WeakReference GetWeakReferenceToDisposableFoo()
{
var udf = Container.Resolve<UsesDisposableFoo>();
var weakUdt = new WeakReference(udf);
udf = null;
return weakUdt;
}

[Test]
public void Transient_depending_on_scoped_component_is_not_tracked_by_the_release_policy()
{
Expand Down