public void UsesPolicyToGetObject() { var mockPolicy = new Mock <ILifetimePolicy>(); var returnValue = new object(); mockPolicy .Setup(x => x.GetInstance()) .Returns(returnValue); var resolver = new ConcreteTypeResolver(mockPolicy.Object); Assert.AreEqual(returnValue, resolver.Resolve()); }
private void RegisterType(bool singleton, Type type) { ILifetimePolicy policy = null; if (singleton) { policy = new SingletonLifetimePolicy(type, this); } else { policy = new TransientLifetimePolicy(type, this); } _resolvers[type] = new ConcreteTypeResolver(policy); }
public void RegisterInstance <T>(T instance) { _resolvers[typeof(T)] = new ConcreteTypeResolver(new SpecifiedInstanceLifetimePolicy(instance)); }