Example #1
0
        public void Test()
        {
            ObjectFactory.Initialize(x => {
                x.ForConcreteType <SomeDbRepository>().Configure.
                Ctor <string>("connectionString").Is("some connection string");

                //x.ForConcreteType<SomeWebPage>().Configure.
                //  SetterDependency<SomeDbRepository>().Is<SomeDbRepository>();

                x.Policies.SetAllProperties(o => o.OfType <SomeDbRepository>());
            });

            var webPage = new SomeWebPage();

            ObjectFactory.BuildUp(webPage);

            webPage.DbRepository.ConnectionString.ShouldEqual("some connection string");
        }
Example #2
0
        public void Test()
        {
            ObjectFactory.Initialize(x => {
                x.ForConcreteType<SomeDbRepository>().Configure.
                    Ctor<string>("connectionString").Is("some connection string");

                //x.ForConcreteType<SomeWebPage>().Configure.
                //  SetterDependency<SomeDbRepository>().Is<SomeDbRepository>();

                x.Policies.SetAllProperties(o => o.OfType<SomeDbRepository>());
            });

            var webPage = new SomeWebPage();

            ObjectFactory.BuildUp(webPage);

            webPage.DbRepository.ConnectionString.ShouldEqual("some connection string");
        }
Example #3
0
        public void Test()
        {
            var container = new Container(x =>
            {
                x.ForConcreteType<SomeDbRepository>().Configure.
                    Ctor<string>("connectionString").Is("some connection string");

                //x.ForConcreteType<SomeWebPage>().Configure.
                //  SetterDependency<SomeDbRepository>().Is<SomeDbRepository>();

                x.Policies.SetAllProperties(o => o.OfType<SomeDbRepository>());
            });

            var webPage = new SomeWebPage();

            container.BuildUp(webPage);

            webPage.DbRepository.ConnectionString.ShouldBe("some connection string");
        }
        public void Test()
        {
            var container = new Container(x =>
            {
                x.ForConcreteType <SomeDbRepository>().Configure.
                Ctor <string>("connectionString").Is("some connection string");

                //x.ForConcreteType<SomeWebPage>().Configure.
                //  SetterDependency<SomeDbRepository>().Is<SomeDbRepository>();

                x.Policies.SetAllProperties(o => o.OfType <SomeDbRepository>());
            });

            var webPage = new SomeWebPage();

            container.BuildUp(webPage);

            webPage.DbRepository.ConnectionString.ShouldBe("some connection string");
        }
        public void Test()
        {
            ObjectFactory.Initialize(x =>
            {
                x.UseDefaultStructureMapConfigFile = false;

                x.ForConcreteType <SomeDbRepository>().Configure.
                WithCtorArg("connectionString").EqualTo("some connection string");

                //x.ForConcreteType<SomeWebPage>().Configure.
                //  SetterDependency<SomeDbRepository>().Is<SomeDbRepository>();

                x.SetAllProperties(o => o.OfType <SomeDbRepository>());
            });

            var dbRepository =
                ObjectFactory.GetInstance <SomeDbRepository>();

            var webPage = new SomeWebPage();

            ObjectFactory.BuildUp(webPage);

            webPage.DbRepository.ConnectionString.ShouldEqual("some connection string");
        }