public void SiteServicesTest() { Control control = (Control)_helper.CreateControl(typeof(TestButton), null); Assert.IsNotNull(control.Site.GetService(typeof(IDictionaryService)), "#1"); Assert.IsNotNull(control.Site.GetService(typeof(INestedContainer)), "#2"); Assert.IsNotNull(control.Site.GetService(typeof(IServiceContainer)), "#3"); // The following two tests show that the DT Site: // * doesn't offer its implementation of IServiceContainer as a site-specific service // * offers the added site-specific services via IServiceProvider // ((IServiceContainer)control.Site).AddService(typeof(DesignSurfaceTest), new DesignSurfaceTest()); Assert.IsNotNull(control.Site.GetService(typeof(DesignSurfaceTest)), "#4"); Assert.AreEqual(control.Site.GetService(typeof(IServiceContainer)), _helper.DesignSurface.GetService(typeof(IServiceContainer)), "#5"); IDictionaryService dictionary = control.Site.GetService(typeof(IDictionaryService)) as IDictionaryService; dictionary.SetValue("val", 15); Assert.AreEqual(15, (int)dictionary.GetValue("val"), "#6"); Assert.AreEqual("val", (string)dictionary.GetKey(15), "#7"); dictionary.SetValue("val", 16); Assert.AreEqual(16, (int)dictionary.GetValue("val"), "#6"); }
public void InitializeTest() { Panel panel = (Panel)_helper.CreateControl(typeof(TestPanel), null); Assert.IsFalse((bool)_helper.GetValue(panel, "AllowDrop"), "#1"); #if MS_NET && NET_1_1 Assert.IsTrue((bool)_helper.GetValue(panel, "SnapToGrid"), "#2"); Assert.IsTrue((bool)_helper.GetValue(panel, "DrawGrid"), "#3"); Assert.AreEqual(new Size(8, 8), (Size)_helper.GetValue(panel, "GridSize"), "#4"); #endif Assert.IsTrue(panel.AllowDrop, "#5"); }
public void InitializeTest() { Button button = (Button)_helper.CreateControl(typeof(TestButton), null); Assert.IsFalse((bool)_helper.GetValue(button, "Locked"), "#1"); Assert.IsTrue((bool)_helper.GetValue(button, "Visible"), "#2"); Assert.IsTrue((bool)_helper.GetValue(button, "Enabled"), "#3"); Assert.IsFalse((bool)_helper.GetValue(button, "AllowDrop"), "#4"); Assert.IsTrue(button.Enabled, "#5"); Assert.IsTrue(button.Visible, "#6"); Assert.IsFalse(button.AllowDrop, "#7"); #if NET_2_0 ControlDesigner buttonDesigner = _helper.IDesignerHost.GetDesigner(button) as ControlDesigner; Assert.AreEqual(null, buttonDesigner.InternalControlDesigner(20)); Assert.AreEqual(0, buttonDesigner.NumberOfInternalControlDesigners()); #endif }