public void Initialize()
        {
            TestIPageViewSite pageViewSite = new TestIPageViewSite();
            TestIPropertyPageUI testPageUI = new TestIPropertyPageUI();
            PropertyControlTable propertyControlTable = new PropertyControlTable();

            string property1Name = "Property1";
            string property1ControlName = "TextBox1";
            string property1Value = "Value1";

            string property2Name = "Property2";
            string property2ControlName = "CheckBox1";
            string property2Value = "true";

            pageViewSite.PropertyNameValueDictionary.Add(property1Name, property1Value);
            pageViewSite.PropertyNameValueDictionary.Add(property2Name, property2Value);

            propertyControlTable.Add(property1Name, property1ControlName);
            propertyControlTable.Add(property2Name, property2ControlName);

            testPageUI.controlValues.Add(property1ControlName, "NotSet");
            testPageUI.controlValues.Add(property2ControlName, "NotSet");

            PropertyControlMap map = new PropertyControlMap(pageViewSite, testPageUI, propertyControlTable);

            map.InitializeControls();
            Assert.AreEqual(2, pageViewSite.RequestedProperties.Count);
            Assert.IsTrue(pageViewSite.RequestedProperties.Contains(property1Name));
            Assert.IsTrue(pageViewSite.RequestedProperties.Contains(property2Name));
            Assert.AreEqual(property1Value, testPageUI.controlValues[property1ControlName]);
            Assert.AreEqual(property2Value, testPageUI.controlValues[property2ControlName]);
            Assert.AreEqual(map, testPageUI.registeringMap);
        }
Ejemplo n.º 2
0
        public void GetBadControlValueTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();
            TestPageView pageView = new TestPageView(testPageViewSite);

            pageView.GetControlValue("label1");
        }
Ejemplo n.º 3
0
        public void ConstructorTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();

            TestPageView target = new TestPageView(testPageViewSite);
            Assert.IsNotNull(target);
        }
        public void ConstructorTest()
        {
            TestIPageViewSite pageViewSite = new TestIPageViewSite();
            TestIPropertyPageUI testPageUI = new TestIPropertyPageUI();
            PropertyControlTable propertyControlTable = new PropertyControlTable();

            PropertyControlMap target = new PropertyControlMap(pageViewSite, testPageUI, propertyControlTable);

            Assert.IsNotNull(target);
        }
        public void IPageViewSiteTest()
        {
            TestIPageViewSite pageViewSite = new TestIPageViewSite();
            TestIPropertyPageUI testPageUI = new TestIPropertyPageUI();
            PropertyControlTable propertyControlTable = new PropertyControlTable();

            PropertyControlMap target = new PropertyControlMap(pageViewSite, testPageUI, propertyControlTable);
            PropertyPageBase_PropertyControlMapAccessor mapAccessor = new PropertyPageBase_PropertyControlMapAccessor(target);

            Assert.AreEqual(pageViewSite, mapAccessor.m_pageViewSite);
        }
Ejemplo n.º 6
0
        public void GetSetControlValueTest()
        {
            TestIPageViewSite testPageView = new TestIPageViewSite();

            TestPageView pageView = new TestPageView(testPageView);

            string value1 = "Value1";
            string value2 = "True";

            pageView.SetControlValue("Control1", value1);
            pageView.SetControlValue("Control2", value2);

            Assert.AreEqual(value1, pageView.GetControlValue("Control1"));
            Assert.AreEqual(value2, pageView.GetControlValue("Control2"));
        }
Ejemplo n.º 7
0
        public void DisposeTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();

            string value1 = "Value1";
            string value2 = "True";
            string value3 = "NotSet";

            testPageViewSite.PropertyNameValueDictionary.Add("Property1", value1);
            testPageViewSite.PropertyNameValueDictionary.Add("Property2", value2);
            testPageViewSite.PropertyNameValueDictionary.Add("Property3", value3);

            TestPageView pageView = new TestPageView(testPageViewSite);
            TestHostingForm hostingForm = new TestHostingForm();
            using (hostingForm)
            {
                pageView.Initialize(hostingForm, hostingForm.ClientRectangle);
                pageView.Dispose();
                pageView.GetControlValue("Control1");
            }
        }
        public void UserEditChangedHandlerTest()
        {
            TestIPageViewSite pageViewSite = new TestIPageViewSite();
            TestIPropertyPageUI testPageUI = new TestIPropertyPageUI();
            PropertyControlTable propertyControlTable = new PropertyControlTable();

            string property1Name = "Property1";
            string property1ControlName = "TextBox1";
            string property1Value = "Value1";
            string property1NewValue = "Changed1";

            pageViewSite.PropertyNameValueDictionary.Add(property1Name, property1Value);
            propertyControlTable.Add(property1Name, property1ControlName);
            testPageUI.controlValues.Add(property1ControlName, "NotSet");

            PropertyControlMap map = new PropertyControlMap(pageViewSite, testPageUI, propertyControlTable);
            map.InitializeControls();

            testPageUI.SimulateUserEdit(property1ControlName, property1NewValue);
            Assert.AreEqual(1, pageViewSite.ChangedProperties.Count);
            Assert.AreEqual(property1NewValue, pageViewSite.ChangedProperties[property1Name]);
        }
        public void RefreshPropertyValuesTest()
        {
            TestIPageViewSite pageViewSite = new TestIPageViewSite();
            TestIPropertyPageUI testPageUI = new TestIPropertyPageUI();
            PropertyControlTable propertyControlTable = new PropertyControlTable();

            string propertyName = "Property";
            string controlName = "Control";
            string initialValue = "Value1";
            string changedValue = "ChangedValue";

            pageViewSite.PropertyNameValueDictionary.Add(propertyName, initialValue);
            propertyControlTable.Add(propertyName, controlName);
            testPageUI.controlValues.Add(controlName, "NotSet");

            PropertyControlMap map = new PropertyControlMap(pageViewSite, testPageUI, propertyControlTable);
            map.InitializeControls();

            Assert.AreEqual(initialValue, testPageUI.controlValues[controlName]);

            pageViewSite.PropertyNameValueDictionary[propertyName] = changedValue;

            map.InitializeControls();

            Assert.AreEqual(changedValue, testPageUI.controlValues[controlName]);
        }
Ejemplo n.º 10
0
        public void InitializeTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();

            string value1 = "Value1";
            string value2 = "True";
            string value3 = "NotSet";

            testPageViewSite.PropertyNameValueDictionary.Add("Property1", value1);
            testPageViewSite.PropertyNameValueDictionary.Add("Property2", value2);
            testPageViewSite.PropertyNameValueDictionary.Add("Property3", value3);

            TestPageView pageView = new TestPageView(testPageViewSite);
            TestHostingForm hostingForm = new TestHostingForm();
            using (hostingForm)
            {
                pageView.Initialize(hostingForm, hostingForm.ClientRectangle);

                Assert.IsTrue(hostingForm.Controls.Contains(pageView));
                Assert.AreEqual(hostingForm.ClientRectangle, pageView.DisplayRectangle);

                Assert.AreEqual(value1, pageView.GetControlValue("Control1"));
                Assert.AreEqual(value2, pageView.GetControlValue("Control2"));
            }
        }
Ejemplo n.º 11
0
        public void m_propertyControlMapTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();

            TestPageView target = new TestPageView(testPageViewSite);
            PropertyPageBase_PageViewAccessor accessor = new PropertyPageBase_PageViewAccessor(target);
            Assert.IsNotNull(accessor.m_propertyControlMap);
        }
Ejemplo n.º 12
0
 public void ViewDoesNotOverridePropertyControlTable()
 {
     TestIPageViewSite pageViewSite = new TestIPageViewSite();
     MockPageView pageView = new MockPageView(pageViewSite);
 }
Ejemplo n.º 13
0
        public void UserEditCompleteTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();

            string value1 = "Value1";
            string value2 = "True";
            string value3 = "NotSet";

            testPageViewSite.PropertyNameValueDictionary.Add("Property1", value1);
            testPageViewSite.PropertyNameValueDictionary.Add("Property2", value2);
            testPageViewSite.PropertyNameValueDictionary.Add("Property3", value3);

            TestPageView pageView = new TestPageView(testPageViewSite);
            TestHostingForm hostingForm = new TestHostingForm();
            using (hostingForm)
            {
                pageView.Initialize(hostingForm, hostingForm.DisplayRectangle);
                string expectedControlName = "Control3";
                string expectedValue = "ValueSet";

                string actualControlName = null;
                string actualValue = null;

                pageView.UserEditComplete += delegate(string controlName, string value) { actualControlName = controlName; actualValue = value; };
                TestTextBox testTextBox = pageView.Controls["Control3"] as TestTextBox;
                testTextBox.Text = expectedValue;
                testTextBox.ValidateNow();
                Assert.AreEqual(expectedControlName, actualControlName);
                Assert.AreEqual(expectedValue, actualValue);

                expectedControlName = "Control2";
                expectedValue = "False";

                CheckBox testCheckBox = pageView.Controls["Control2"] as CheckBox;
                testCheckBox.Checked = false;
                Assert.AreEqual(expectedControlName, actualControlName);
                Assert.AreEqual(expectedValue, actualValue);
            }
        }
Ejemplo n.º 14
0
        public void ShowViewHideViewTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();

            TestPageView pageView = new TestPageView(testPageViewSite);
            pageView.ShowView();
            Assert.IsTrue(pageView.Visible, "Page's Visible property is false");
            pageView.HideView();
            Assert.IsFalse(pageView.Visible, "Page's Visisble property is true");
        }
Ejemplo n.º 15
0
        public void PropertyControlTableTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();

            TestPageView pageView = new TestPageView(testPageViewSite);
            PropertyPageBase_PageViewAccessor pageViewAccessor = new PropertyPageBase_PageViewAccessor(pageView);
            PropertyPageBase_PropertyControlMapAccessor mapAccessor = new PropertyPageBase_PropertyControlMapAccessor(pageViewAccessor.m_propertyControlMap);
            Assert.AreEqual(pageView.Table, mapAccessor.m_propertyControlTable);
        }
Ejemplo n.º 16
0
        public void ProcessAcceleratorTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();

            TestPageView pageView = new TestPageView(testPageViewSite);

            TestControl testControl = new TestControl();
            testControl.MessagesIRecognize.Add(int.MaxValue - 1);
            pageView.Controls.Add(testControl);
            testControl.CreateControl();

            Message recognizedMessage = new Message();
            recognizedMessage.Msg = int.MaxValue - 1;
            recognizedMessage.LParam = new IntPtr(1);
            recognizedMessage.WParam = new IntPtr(2);
            recognizedMessage.HWnd = testControl.Handle;

            Message unrecognizedMessage = new Message();
            unrecognizedMessage.Msg = int.MaxValue;
            unrecognizedMessage.LParam = new IntPtr(1);
            unrecognizedMessage.WParam = new IntPtr(2);
            unrecognizedMessage.HWnd = testControl.Handle;

            int hr = pageView.ProcessAccelerator(ref recognizedMessage);
            Assert.AreEqual(VSConstants.S_OK, hr);
            Assert.IsTrue(testControl.MessagesAskedToProcess.Contains(recognizedMessage));

            hr = pageView.ProcessAccelerator(ref unrecognizedMessage);
            Assert.AreEqual(VSConstants.S_FALSE, hr);
            Assert.IsFalse(testControl.MessagesAskedToProcess.Contains(unrecognizedMessage));
        }
Ejemplo n.º 17
0
        public void PropertyControlTableTest()
        {
            TestIPageViewSite pageViewSite = new TestIPageViewSite();
            TestIPropertyPageUI testPageUI = new TestIPropertyPageUI();
            PropertyControlTable propertyControlTable = new PropertyControlTable();
            string expectedPropertyName = "Property";
            string expectedControlName = "Control";
            propertyControlTable.Add(expectedPropertyName, expectedControlName);

            PropertyControlMap target = new PropertyControlMap(pageViewSite, testPageUI, propertyControlTable);
            PropertyPageBase_PropertyControlMapAccessor mapAccessor = new PropertyPageBase_PropertyControlMapAccessor(target);

            Assert.AreEqual(expectedControlName, mapAccessor.m_propertyControlTable.GetControlNameFromPropertyName(expectedPropertyName));
        }
Ejemplo n.º 18
0
        public void MoveViewTest()
        {
            TestIPageViewSite testPageViewSite = new TestIPageViewSite();

            string value1 = "Value1";
            string value2 = "True";
            string value3 = "NotSet";

            testPageViewSite.PropertyNameValueDictionary.Add("Property1", value1);
            testPageViewSite.PropertyNameValueDictionary.Add("Property2", value2);
            testPageViewSite.PropertyNameValueDictionary.Add("Property3", value3);
            TestPageView pageView = new TestPageView(testPageViewSite);

            TestHostingForm hostingForm = new TestHostingForm();
            using (hostingForm)
            {
                pageView.Initialize(hostingForm, hostingForm.ClientRectangle);
                Rectangle newRectangle = hostingForm.ClientRectangle;
                newRectangle.Width = newRectangle.Width - 1;
                newRectangle.Height = newRectangle.Height - 1;
                pageView.MoveView(newRectangle);
                Assert.AreEqual(newRectangle, pageView.DisplayRectangle);
            }
        }