public void WhenComponentIsRegistered_IsRegisteredReturnsTrueForAllServices()
        {
            var registration = Factory.CreateSingletonRegistration(
                new[] { new TypedService(typeof(object)), new TypedService(typeof(string)) },
                Factory.CreateProvidedInstanceActivator("Hello"));

            var target = new Container();

            target.ComponentRegistry.Register(registration);

            Assert.True(target.IsRegistered<object>());
            Assert.True(target.IsRegistered<string>());
        }
Example #2
0
        public void ResolveByName()
        {
            string name = "name";

            var r = Factory.CreateSingletonRegistration(
                new Service[] { new KeyedService(name, typeof(string)) },
                Factory.CreateReflectionActivator(typeof(object)));

            var c = new Container();
            c.ComponentRegistry.Register(r);

            object o;

            Assert.True(c.TryResolveNamed(name, typeof(string), out o));
            Assert.NotNull(o);

            Assert.False(c.IsRegistered<object>());
        }
Example #3
0
 public void ContainerProvidesILifetimeScopeAndIContext()
 {
     var container = new Container();
     Assert.IsTrue(container.IsRegistered<ILifetimeScope>());
     Assert.IsTrue(container.IsRegistered<IComponentContext>());
 }