public void MatchesAgainstMultipleTaggedScopes() { const string tag1 = "Tag1"; const string tag2 = "Tag2"; var msl = new MatchingScopeLifetime(tag1, tag2); var container = new Container(); var tag1Scope = (ISharingLifetimeScope)container.BeginLifetimeScope(tag1); Assert.Equal(tag1Scope, msl.FindScope(tag1Scope)); var tag2Scope = (ISharingLifetimeScope)container.BeginLifetimeScope(tag2); Assert.Equal(tag2Scope, msl.FindScope(tag2Scope)); }
public void MatchesAgainstSingleTaggedScope() { const string tag = "Tag"; var msl = new MatchingScopeLifetime(tag); var container = new Container(); var lifetimeScope = (ISharingLifetimeScope)container.BeginLifetimeScope(tag); Assert.Equal(lifetimeScope, msl.FindScope(lifetimeScope)); }
public void AdaptersInNestedScopeOverrideAdaptersInParent() { const string parentInstance = "p"; const string childInstance = "c"; var parent = new Container(); parent.ComponentRegistry.AddRegistrationSource(new ObjectRegistrationSource(parentInstance)); var child = parent.BeginLifetimeScope(builder => builder.RegisterSource(new ObjectRegistrationSource(childInstance))); var fromChild = child.Resolve<object>(); Assert.Same(childInstance, fromChild); }
public void ResolvingLifetimeScopeProvidesCurrentScope() { var c = new Container(); var l = c.BeginLifetimeScope(); Assert.AreSame(l, l.Resolve<ILifetimeScope>()); }
public void ResolvingComponentContextProvidesCurrentScope() { var c = new Container(); var l = c.BeginLifetimeScope(); Assert.Same(l, l.Resolve<IComponentContext>()); }