container
container copied to clipboard
ExternallyControlledLifetimeManager returns null instead of LifetimeManager.NoValue
Description
When object referenced by ExternallyControlledLifetimeManager goes out of scope and is collected by the Garbage Collector the manager returns null instead of LifetimeManager.NoValue.
To Reproduce
[TestMethod]
public void CollectedTest()
{
// Arrange
var instance = new object();
TestManager.SetValue(instance, LifetimeContainer);
instance = TestManager.GetValue(LifetimeContainer);
Assert.AreNotSame(LifetimeManager.NoValue, instance);
// Act
instance = null;
GC.Collect();
GC.WaitForPendingFinalizers();
// Validate
var after = TestManager.GetValue(LifetimeContainer); <-- returns null
Assert.AreSame(LifetimeManager.NoValue, after);
}