Esempio n. 1
0
        public BuildUpTester()
        {
            theDefaultGateway = new DefaultGateway();

            var args = new ExplicitArguments();
            args.Set<IGateway>(theDefaultGateway);
            session = BuildSession.Empty(args);

            theDependencies = new DependencyCollection { { "Age", 34 } };

            target = null;
        }
        public void use_predefined_setter_values_for_buildup()
        {
            var theGateway = new DefaultGateway();
            var container = new Container(x => {
                x.ForConcreteType<BuildUpTarget1>().Configure
                    .Setter(y => y.Gateway).Is(theGateway);
            });

            var target = new BuildUpTarget1();
            container.BuildUp(target);

            target.Gateway.ShouldBeTheSameAs(theGateway);
        }
Esempio n. 3
0
        public void SetUp()
        {
            TheDefaultGateway = new DefaultGateway();

            var args = new ExplicitArguments();
            args.Set<IGateway>(TheDefaultGateway);

            builder = new Plugin(typeof (ClassWithMixOfSetters)).CreateBuilder();
            instance = new SmartInstance<ClassWithMixOfSetters>().Ctor<int>("Age").Is(34);
            _session = BuildSession.Empty(args);

            _target = null;
        }
Esempio n. 4
0
        public void SetUp()
        {
            TheDefaultGateway = new DefaultGateway();


            var args = new ExplicitArguments();
            args.Set<IGateway>(TheDefaultGateway);
            _session = BuildSession.Empty(args);

            theDependencies = new DependencyCollection {{"Age", 34}};


            _target = null;
        }
        public void create_a_setter_rule_and_see_it_applied_in_BuildUp()
        {
            var theGateway = new DefaultGateway();
            var container = new Container(x => {
                x.For<IGateway>().Use(theGateway);
                x.Policies.SetAllProperties(y => { y.OfType<IGateway>(); });
            });

            var target = new BuildUpTarget1();
            container.BuildUp(target);

            target.Gateway.ShouldBeTheSameAs(theGateway);
            target.Service.ShouldBeNull();
        }
        public void create_a_setter_rule_and_see_it_applied_in_BuildUp_through_ObjectFactory()
        {
            var theGateway = new DefaultGateway();
            var container = new Container(x => {
                x.For<IGateway>().Use(theGateway);

                // First we create a new Setter Injection Policy that
                // forces StructureMap to inject all public properties
                // where the PropertyType is IGateway
                x.Policies.SetAllProperties(y => y.OfType<IGateway>());
            });

            // Create an instance of BuildUpTarget1
            var target = new BuildUpTarget1();

            // Now, call BuildUp() on target, and
            // we should see the Gateway property assigned
            container.BuildUp(target);

            target.Gateway.ShouldBeTheSameAs(theGateway);
        }
        public void create_a_setter_rule_and_see_it_applied_in_BuildUp_through_ObjectFactory()
        {
            var theGateway = new DefaultGateway();
            ObjectFactory.Initialize(x =>
            {
                x.IgnoreStructureMapConfig = true;
                x.ForRequestedType<IGateway>().TheDefault.IsThis(theGateway);

                // First we create a new Setter Injection Policy that
                // forces StructureMap to inject all public properties
                // where the PropertyType is IGateway
                x.SetAllProperties(y => { y.OfType<IGateway>(); });
            });

            // Create an instance of BuildUpTarget1
            var target = new BuildUpTarget1();

            // Now, call BuildUp() on target, and
            // we should see the Gateway property assigned
            ObjectFactory.BuildUp(target);

            target.Gateway.ShouldBeTheSameAs(theGateway);
        }