public void DeactivateTest()
 {
     TestPage testPage = new TestPage();
     TestIPropertyPageSite testSite = new TestIPropertyPageSite();
     testPage.SetPageSite(testSite);
     Mocks.TestHostingForm hostingForm = new PropertyPageBaseTest.Mocks.TestHostingForm();
     using (hostingForm)
     {
         hostingForm.CreateControl();
         RECT hostingRectangle;
         hostingRectangle.left = 0;
         hostingRectangle.top = 0;
         hostingRectangle.right = 100;
         hostingRectangle.bottom = 100;
         testPage.Activate(hostingForm.Handle, new RECT[] { hostingRectangle } , 0);
         TestIPageView pageView = testPage.MyPageView as TestIPageView;
         Assert.AreEqual(hostingForm, pageView.MyParent);
         testPage.Deactivate();
         Assert.IsNull(pageView.MyParent);
     }
 }
        public void PropertyChangedTest()
        {
            TestPage testPage = new TestPage();

            string dummyObject = "dummy";
            string propertyName = "Property1";
            string expectedValue = "Value1";
            string newValue = "Value2";

            TestIPropertyPageSite site = new TestIPropertyPageSite();
            site.page = testPage;

            testPage.SetPageSite(site);
            testPage.SetObjects(1, new object[] { dummyObject });
            TestIPropertyStore testPropertyStore = testPage.IPropertyStore as TestIPropertyStore;
            testPropertyStore.Properties.Add(propertyName, expectedValue);

            testPage.PropertyChanged(propertyName, newValue);
            Assert.AreEqual((uint)(PROPPAGESTATUS.PROPPAGESTATUS_VALIDATE | PROPPAGESTATUS.PROPPAGESTATUS_DIRTY), site.StatusChangeFlags);
            Assert.AreEqual(newValue, testPropertyStore.Properties[propertyName]);
        }
        public void IsPageDirtyTest()
        {
            TestPage testPage = new TestPage();

            TestIPropertyPageSite site = new TestIPropertyPageSite();
            site.ImmediateApply = false;
            site.page = testPage;

            string propertyName = "PropertyName";
            string propertyValue = "PropertyValue";
            string newValue = "PropertyValueNew";
            string dummyObject = "DummyObject";

            testPage.SetPageSite(site);
            testPage.SetObjects(1, new object[] { dummyObject });
            TestIPropertyStore testPropertyStore = testPage.IPropertyStore as TestIPropertyStore;
            testPropertyStore.Properties.Add(propertyName, propertyValue);

            bool actual = testPage.IsPageDirty() == VSConstants.S_OK;
            Assert.AreEqual(false, actual);

            testPage.PropertyChanged(propertyName, newValue);
            actual = testPage.IsPageDirty() == VSConstants.S_OK;
            Assert.AreEqual(true, actual);

            testPage.Apply();
            actual = testPage.IsPageDirty() == VSConstants.S_OK;
            Assert.AreEqual(false, actual);
        }
        public void MoveTest()
        {
            TestPage samplePage = new TestPage();
            TestIPropertyPageSite testSite = new TestIPropertyPageSite();

            samplePage.SetPageSite(testSite);
            Mocks.TestHostingForm hostingForm = new PropertyPageBaseTest.Mocks.TestHostingForm();
            using (hostingForm)
            {
                hostingForm.CreateControl();
                RECT hostingRectangle;
                hostingRectangle.left = 0;
                hostingRectangle.top = 0;
                hostingRectangle.right = 100;
                hostingRectangle.bottom = 100;
                samplePage.Activate(hostingForm.Handle, new RECT[] { hostingRectangle } , 0);
                hostingRectangle.left = 0;
                hostingRectangle.top = 0;
                hostingRectangle.right = 90;
                hostingRectangle.bottom = 90;
                samplePage.Move(new RECT[] { hostingRectangle });
                TestIPageView pageView = samplePage.MyPageView as TestIPageView;
                Assert.AreEqual(Rectangle.FromLTRB(0, 0, 90, 90), pageView.MyLocation);
            }
        }
        public void HelpTest()
        {
            TestPage testPage = new TestPage();
            TestIPropertyPageSite testSite = new TestIPropertyPageSite();
            TestHelp testHelp = new TestHelp();
            testSite.ServiceObjects.Add(typeof(Microsoft.VisualStudio.VSHelp.Help), testHelp);

            testPage.SetPageSite(testSite);
            testPage.Help("");
            Assert.AreEqual("TestPageHelp", testHelp.KeywordsDisplayed[0]);
        }