Skip to content

Commit ccf9a78

Browse files
NefarionThomas
and
Thomas
authored
GHIssue340_WaitForItemIsSet_does_never_end (#341)
Co-authored-by: Thomas <[email protected]>
1 parent 4b2e736 commit ccf9a78

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using NUnit.Framework;
2+
using System;
3+
4+
namespace DryIoc.IssuesTests
5+
{
6+
[TestFixture]
7+
public class GHIssue340_WaitForItemIsSet_does_never_end
8+
{
9+
[Test]
10+
[Ignore("fixme")]
11+
public void WaitForItemIsSet_does_never_end()
12+
{
13+
var c = new Container();
14+
c.Register<Session>(Reuse.Singleton);
15+
c.Register<Instance>(Reuse.Scoped);
16+
c.Register<Func<string, Instance>>(Reuse.Singleton, Made.Of(() => Factory.Make(Arg.Of<Func<Session>>())));
17+
var session = c.Resolve<Session>();
18+
}
19+
20+
class Factory
21+
{
22+
public static Func<string, Instance> Make(Func<Session> session) => str => session().GetScopeForContext(str)?.Resolve<Instance>();
23+
}
24+
25+
class Session
26+
{
27+
IResolverContext _scope;
28+
public Session(IContainer cont)
29+
{
30+
_scope = cont.OpenScope("test");
31+
var dep = cont.New<Dependency>();
32+
}
33+
34+
// I use the string as placeholder now, it is for scope lookup
35+
public IResolverContext GetScopeForContext(string ctx) => _scope;
36+
}
37+
38+
class Instance { }
39+
40+
class Dependency
41+
{
42+
public Dependency(Func<string, Instance> instCtor)
43+
{
44+
var inst = instCtor("test");
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)