Esempio n. 1
0
        public void set_and_get_a_collection()
        {
            var children = new Instance[]
            {
                new SmartInstance <ColorWidget>().WithCtorArg("color").EqualTo("red"),
                new SmartInstance <ColorWidget>().WithCtorArg("color").EqualTo("green"),
                new ObjectInstance(new AWidget())
            };

            ConstructorInstance instance = ConstructorInstance.For <ClassWithArrayOfWidgets>();

            instance.SetCollection("widgets", children);


            var widgets = instance.Get("widgets", typeof(IWidget), new StubBuildSession()).ShouldBeOfType <IWidget[]>();


            widgets.Length.ShouldEqual(3);

            widgets[0].ShouldBeOfType <ColorWidget>().Color.ShouldEqual("red");
            widgets[2].ShouldBeOfType <AWidget>();
        }