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"); }
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"); }
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"); }
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"); }