public void ShouldResolveAllInterfaces()
    {
        var builder = new UnityObjectBuilder();


        builder.Configure(typeof(First), DependencyLifecycle.InstancePerCall);

        builder.Configure(typeof(Second), DependencyLifecycle.InstancePerCall);

        var result = builder.BuildAll(typeof(ISomeInterface));

        Assert.AreEqual(2, result.Count());
    }
Esempio n. 2
0
    public void ShouldResolveInterfaces()
    {
        var builder = new UnityObjectBuilder();


        builder.Configure(typeof(SomeClass), DependencyLifecycle.InstancePerCall);


        var result = builder.Build(typeof(ISomeInterface));

        Assert.IsInstanceOf <SomeClass>(result);
    }
Esempio n. 3
0
        public void Existing_instances_registred_in_the_container_can_be_injected_via_constructor()
        {
            var container = new UnityContainer();

            var builder = new UnityObjectBuilder(container);

            builder.Configure(typeof(ConstructorInjectionHandler), DependencyLifecycle.InstancePerCall);

            container.RegisterInstance <ISomeInterface>(new SomeClass());

            var result = (ConstructorInjectionHandler)builder.Build(typeof(ConstructorInjectionHandler));

            Assert.IsNotNull(result.Dependency);
        }