public void build_an_object_with_a_list_dependency()
        {
            var def = new ObjectDef(typeof (ClassWithSomethings));

            var listDependency = def.ListDependenciesOf<ISomething>();

            listDependency.AddType(typeof (SomethingA));
            listDependency.AddType(typeof (SomethingB));
            listDependency.AddValue(new SomethingC());

            var instance = new ObjectDefInstance(def);

            var container = new Container();
            var @object = container.GetInstance<ClassWithSomethings>(instance);

            @object.Somethings[0].ShouldBeOfType<SomethingA>();
            @object.Somethings[1].ShouldBeOfType<SomethingB>();
            @object.Somethings[2].ShouldBeOfType<SomethingC>();
        }
Ejemplo n.º 2
0
        public void build_an_object_with_a_list_dependency()
        {
            var def = new ObjectDef(typeof(ClassWithSomethings));


            var listDependency = def.ListDependenciesOf <ISomething>();

            listDependency.AddType(typeof(SomethingA));
            listDependency.AddType(typeof(SomethingB));
            listDependency.AddValue(new SomethingC());

            var instance = new ObjectDefInstance(def);

            var container = new Container();
            var @object   = container.GetInstance <ClassWithSomethings>(instance);

            @object.Somethings[0].ShouldBeOfType <SomethingA>();
            @object.Somethings[1].ShouldBeOfType <SomethingB>();
            @object.Somethings[2].ShouldBeOfType <SomethingC>();
        }