public void SingletonProxy() { using (var resolver = new TactContainer(new InMemoryLog())) { resolver.RegisterSingleton <IOne, One>(); resolver.RegisterProxy <ITwo, IOne>(); var two = resolver.Resolve <ITwo>(); var one = resolver.Resolve <IOne>(); Assert.Same(one, two); } }
public void PerScopeProxy() { using (var resolver = new TactContainer(new InMemoryLog())) { resolver.RegisterPerScope <IOne, One>(); resolver.RegisterProxy <ITwo, IOne>(); var twoA = resolver.Resolve <ITwo>(); var oneA = resolver.Resolve <IOne>(); Assert.Same(oneA, twoA); using (var scope = resolver.BeginScope()) { var twoB = scope.Resolve <ITwo>(); var oneB = scope.Resolve <IOne>(); Assert.Same(oneB, twoB); Assert.NotSame(oneA, oneB); } } }