Example #1
0
        public void in_testing()
        {
            var container = new Container(_ =>
            {
                _.For<IService>().Use<TheRealService>();
            });

            // Create a new child container for only this test
            var testContainer = container.CreateChildContainer();

            // Override a service with a stub that's easier to control
            var stub = new StubbedService();
            testContainer.Inject<IService>(stub);

            // Now, continue with the test resolving application
            // services through the new child container....
        }
Example #2
0
        public void in_testing()
        {
            var container = new Container(_ =>
            {
                _.For <IService>().Use <TheRealService>();
            });

            // Create a new child container for only this test
            var testContainer = container.CreateChildContainer();

            // Override a service with a stub that's easier to control
            var stub = new StubbedService();

            testContainer.Inject <IService>(stub);

            // Now, continue with the test resolving application
            // services through the new child container....
        }