-
-
Notifications
You must be signed in to change notification settings - Fork 72
Closed
Labels
releaseRelease branchRelease branch
Description
Description
It's not the same as unitycontainer/interception#30, but perhaps it is related to each other. The following test is failed both for .NET Core and Framework. Look at the comments in the code to more information.
To Reproduce
[Test]
public void UnityTest()
{
for (var i = 0; i < 10000; i++) {
var container = new UnityContainer()
.RegisterType<IFoo, Foo>()
.RegisterType<IBar, Bar>()
// It's important the name is random
.RegisterType<IBar, Bar>(Guid.NewGuid().ToString());
var child = container
.CreateChildContainer()
.RegisterType<IFoo, Foo>(new ContainerControlledLifetimeManager());
var registrations = child.Registrations
.Where(r => r.RegisteredType == typeof(IFoo))
.ToList();
Assert.IsNotNull(
registrations.FirstOrDefault(r => r.LifetimeManager is ContainerControlledLifetimeManager),
"Singleton registration not found on iteration #" + i);
// This check fails on random iteration, usually i < 300.
// It passes for v.5.8.13 but fails for v.5.9.0 and later both for .NET Core and for Framework.
Assert.IsNull(
registrations.FirstOrDefault(r => r.LifetimeManager is TransientLifetimeManager),
"Transient registration found on iteration #" + i);
}
}
public interface IFoo { }
public class Foo : IFoo { }
public interface IBar { }
public class Bar : IBar { }Expected behavior
There must be no transient registration in the child container, but it is on random iteration.
Metadata
Metadata
Assignees
Labels
releaseRelease branchRelease branch