Inheritance: System.Web.UI.Control, ISupportsWebDependencyInjection
        public void DealsWithControlsImplementingISupportsWebDependencyInjection()
        {
            Control rootControl = GetRootControl();

            Control ctl = new ControlSupportingWebDI();

            rootControl.Controls.Add(ctl);

            MockControl subControl = new MockControl();

            ctl.Controls.Add(subControl);
            Assert.IsTrue(subControl.GotIt);

            MockControl subControl2 = new MockControl();

            ctl.Controls.AddAt(0, subControl2);
            Assert.IsTrue(subControl2.GotIt);
        }
        public void SetsApplicationContextOnIApplicationContextAware()
        {
            using (new TestWebContext("/", "context.aspx"))
            {
                Control rootControl = GetRootControl();

                Control ctl = new ControlSupportingWebDI();
                rootControl.Controls.Add(ctl);

                MockControl subControl = new MockControl();
                ctl.Controls.Add(subControl);
                Assert.IsTrue(subControl.GotIt);
                Assert.IsNotNull(subControl.ApplicationContext);
                Assert.IsTrue(ContextRegistry.GetContext() == subControl.ApplicationContext);

                // controls get AppContext from to their location (if any)
                MockControl subControl2 = new MockControl("/controls");
                ctl.Controls.AddAt(0, subControl2);
                Assert.IsTrue(subControl2.GotIt);
                Assert.IsNotNull(subControl2.ApplicationContext);
                Assert.IsTrue(ContextRegistry.GetContext("/controls/") == subControl2.ApplicationContext);
            }
        }
        public void SetsApplicationContextOnIApplicationContextAware()
        {
            using (new TestWebContext("/", "context.aspx"))
            {
                Control rootControl = GetRootControl();

                Control ctl = new ControlSupportingWebDI();
                rootControl.Controls.Add(ctl);

                MockControl subControl = new MockControl();
                ctl.Controls.Add(subControl);
                Assert.IsTrue(subControl.GotIt);
                Assert.IsNotNull(subControl.ApplicationContext);
                Assert.IsTrue(ContextRegistry.GetContext() == subControl.ApplicationContext);

                // controls get AppContext from to their location (if any)
                MockControl subControl2 = new MockControl("/controls");
                ctl.Controls.AddAt(0, subControl2);
                Assert.IsTrue(subControl2.GotIt);
                Assert.IsNotNull(subControl2.ApplicationContext);
                Assert.IsTrue(ContextRegistry.GetContext("/controls/") == subControl2.ApplicationContext);
            }
        }
        public void DealsWithControlsImplementingISupportsWebDependencyInjection()
        {
            Control rootControl = GetRootControl();

            Control ctl = new ControlSupportingWebDI();
            rootControl.Controls.Add(ctl);

            MockControl subControl = new MockControl();
            ctl.Controls.Add(subControl);
            Assert.IsTrue(subControl.GotIt);

            MockControl subControl2 = new MockControl();
            ctl.Controls.AddAt(0, subControl2);
            Assert.IsTrue(subControl2.GotIt);
        }