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 NameTest() { Container container = new Container(); Component owner = new Component(); container.Add(owner, "OwnerName"); NestedContainerTest nestedContainer = new NestedContainerTest(owner); Component nestedComponent = new Component(); nestedContainer.Add(nestedComponent, "NestedComponentName"); Assert.AreEqual("OwnerName", nestedContainer.OwnerName, "#1"); Assert.AreEqual("OwnerName.NestedComponentName", ((INestedSite)nestedComponent.Site).FullName, "#2"); // Prooves that MSDN is wrong. Assert.AreEqual("NestedComponentName", nestedComponent.Site.Name, "#3"); container.Remove(owner); Assert.AreEqual(null, nestedContainer.OwnerName, "#4"); Assert.AreEqual("NestedComponentName", ((INestedSite)nestedComponent.Site).FullName, "#5"); }
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 NameTest () { Container container = new Container (); Component owner = new Component (); container.Add (owner, "OwnerName"); NestedContainerTest nestedContainer = new NestedContainerTest (owner); Component nestedComponent = new Component (); nestedContainer.Add (nestedComponent, "NestedComponentName"); Assert.AreEqual ("OwnerName", nestedContainer.OwnerName, "#1"); Assert.AreEqual ("OwnerName.NestedComponentName", ((INestedSite)nestedComponent.Site).FullName, "#2"); // Prooves that MSDN is wrong. Assert.AreEqual ("NestedComponentName", nestedComponent.Site.Name, "#3"); container.Remove (owner); Assert.AreEqual (null, nestedContainer.OwnerName, "#4"); Assert.AreEqual ("NestedComponentName", ((INestedSite)nestedComponent.Site).FullName, "#5"); }