Skip to content

Commit deb9ee4

Browse files
author
maximv
committed
updated the test for the #337
1 parent 91777cf commit deb9ee4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/DryIoc.IssuesTests/GHIssue337_Singleton_is_created_twice.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,23 @@ public class GHIssue337_Singleton_is_created_twice
1111
[Test]
1212
public void Test()
1313
{
14-
var container = new Container();
15-
container.Register<A>(Reuse.Singleton);
14+
var container = new Container(r => r.WithoutThrowOnRegisteringDisposableTransient());
15+
16+
container.Register<IA, A>(Reuse.Singleton, ifAlreadyRegistered: IfAlreadyRegistered.Replace);
1617

1718
var ts = new Task[8];
1819
for (int i = 0; i < ts.Length; i++)
1920
{
20-
ts[i] = Task.Run(() => container.Resolve<A>());
21+
ts[i] = Task.Run(() => container.Resolve<IA>());
2122
}
2223

2324
Task.WaitAll(ts);
25+
Assert.AreEqual(1, A.Counter);
2426
}
2527

26-
class A
28+
interface IA {}
29+
30+
class A : IA
2731
{
2832
public static int Counter;
2933
public A()

0 commit comments

Comments
 (0)