Пример #1
0
        public void DesignModeTest()
        {
            ContainerWithService container = new ContainerWithService();
            Component            owner     = new Component();

            container.Add(owner, "OwnerName");
            NestedContainerTest nestedContainer = new NestedContainerTest(owner);
            Component           nestedComponent = new Component();

            nestedContainer.Add(nestedComponent, "NestedComponentName");

            Assert.IsTrue(nestedComponent.Site.DesignMode, "#1");
        }
Пример #2
0
        public void GetServiceTest()
        {
            ContainerWithService container = new ContainerWithService();
            Component            owner     = new Component();

            container.Add(owner, "OwnerName");
            NestedContainerTest nestedContainer = new NestedContainerTest(owner);
            Component           nestedComponent = new Component();

            nestedContainer.Add(nestedComponent, "NestedComponentName");

            Assert.IsNotNull(nestedComponent.Site.GetService(typeof(INestedContainer)), "#1");
            // test who provides the ISite service.
            Assert.AreEqual(nestedComponent.Site, nestedComponent.Site.GetService(typeof(ISite)), "#2");
            // test GetService forwarding to owner. Prooves that MSDN is wrong
            Assert.IsNull(nestedComponent.Site.GetService(typeof(ContainerWithService)), "#3");
        }
Пример #3
0
		public void DesignModeTest ()
		{
			ContainerWithService container = new ContainerWithService ();
			Component owner = new Component ();
			container.Add (owner, "OwnerName");
			NestedContainerTest nestedContainer = new NestedContainerTest (owner);
			Component nestedComponent = new Component ();
			nestedContainer.Add (nestedComponent, "NestedComponentName");

			Assert.IsTrue (nestedComponent.Site.DesignMode, "#1");
		}
Пример #4
0
		public void GetServiceTest ()
		{
			ContainerWithService container = new ContainerWithService ();
			Component owner = new Component ();
			container.Add (owner, "OwnerName");
			NestedContainerTest nestedContainer = new NestedContainerTest (owner);
			Component nestedComponent = new Component ();
			nestedContainer.Add (nestedComponent, "NestedComponentName");

			Assert.IsNotNull (nestedComponent.Site.GetService (typeof (INestedContainer)), "#1");
			// test who provides the ISite service.
			Assert.AreEqual (nestedComponent.Site, nestedComponent.Site.GetService (typeof (ISite)), "#2");
			// test GetService forwarding to owner. Prooves that MSDN is wrong
			Assert.IsNull (nestedComponent.Site.GetService (typeof (ContainerWithService)), "#3");
		}