Наследование: System.Web.UI.Page
Пример #1
0
        public void ApplyWithNoUserChangeTest()
        {
            TestPage testPage = new TestPage();

            IPropertyPage page = testPage as IPropertyPage2;
            int actual = page.Apply();
            Assert.AreEqual(VSConstants.S_OK, actual);
        }
Пример #2
0
        public void Resolve_CachePageStatePersister() {
            if(IoC.IsInitialized)
                IoC.Reset();

            IoC.InitializeWithEmptyContainer();
            IoC.Container.Register(Component
                                       .For<IServerPageStatePersister>()
                                       .ImplementedBy(typeof(SysCachePageStatePersister))
                                       .LifeStyle.Is(LifestyleType.Transient));

            var page = new TestPage();
            var persister = ResolvePageStatePersister(page);

            Assert.IsNotNull(persister);
            Assert.IsInstanceOf<SysCachePageStatePersister>(persister);
        }
Пример #3
0
        public void ScriptFileRendersTypeAttributeAndUsesScriptsRootPath()
        {
            const string SCRIPTFILEPATH = "filepath";

            using (new TestWebContext("/", "testpage.aspx"))
            {
                TestPage page = new TestPage(HttpContext.Current);
                Head     head = new Head();
                page.Controls.Add(head);

                page.ScriptsRoot = "testscriptroot";
                page.RegisterHeadScriptFile("filename", SCRIPTFILEPATH);

                string result = page.Render(string.Empty);
                string expect = string.Format(@"<head><script type=""text/javascript"" src=""/testscriptroot/{0}""></script></head>", SCRIPTFILEPATH);
                Assert.AreEqual(expect, result);
            }
        }
Пример #4
0
        public void DontRenderHeadTagIfNestedWithinStandardHeadControl()
        {
            using (new TestWebContext("/", "testpage.aspx"))
            {
                TestPage page     = new TestPage(HttpContext.Current);
                HtmlHead htmlHead = new HtmlHead();
                Head     head     = new Head();
                head.Controls.Add(new LiteralControl("literal child"));
                htmlHead.Controls.Add(head);
                page.Controls.Add(htmlHead);

                // initialize page to force head control initialization
                page.InitRecursive(null);
                string result = page.Render(string.Empty);
                string expect = @"<head>literal child<title></title></head>";
                Assert.AreEqual(expect, result);
            }
        }
Пример #5
0
        public void StyleFileRendersTypeAttributeAndUsesCssRootPath()
        {
            const string STYLESHEETPATH = "filepath";

            using (new TestWebContext("/", "testpage.aspx"))
            {
                TestPage page = new TestPage(HttpContext.Current);
                Head     head = new Head();
                page.Controls.Add(head);

                page.CssRoot = "testcssroot";
                page.StyleFiles.Add("filename", STYLESHEETPATH);

                string result = page.Render(string.Empty);
                string expect = string.Format(@"<head><link rel=""stylesheet"" type=""text/css"" href=""/testcssroot/{0}"" /></head>", STYLESHEETPATH);
                Assert.AreEqual(expect, result);
            }
        }
Пример #6
0
        public void Create_WhenGivenTypedSourceObject_ShouldReturnValidHALResource()
        {
            var source = new TestPage()
            {
                Name = "Test", Owner = new User()
                {
                    Id = "oveand", Name = "Ove Andersen"
                }
            };

            var result = this.factory.Create(source);

            Assert.AreEqual(source.Name, result.State.Name);
            Assert.IsNull(result.State.Owner);
            Assert.AreEqual("oveand", result.EmbeddedResources["Owner"].ToResource <User>().State.Id);
            Assert.AreEqual("Ove Andersen", result.EmbeddedResources["Owner"].ToResource <User>().State.Name);
            Assert.IsNull(result.Links);
        }
Пример #7
0
        public void SetResultThrowsVerboseExceptionOnUnknownResultName()
        {
            string RESULTNAME = "nonexistant result";

            TestPage page = new TestPage();

            try
            {
                page.SetResult(RESULTNAME);
                Assert.Fail();
            }
            catch (ArgumentException ae)
            {
                string expected = string.Format("No mapping found for the specified destination '{0}'.", RESULTNAME);
                string msg      = ae.Message.Substring(0, expected.Length);
                Assert.AreEqual(expected, msg);
            }
        }
Пример #8
0
        public void Validate()
        {
            Page page = new TestPage(HttpContext.Current);

            IValidator[] validators = new IValidator[] { new RequiredValidator("Name", null), new ConditionValidator("Loan == 0", "Age > 21") };
            Contact      contact    = new Contact("Goran", 24, 0);
            bool         result     = page.Validate(contact, validators);

            Assert.IsTrue(result);

            contact = new Contact(null, 24, 0);
            result  = page.Validate(contact, validators);
            Assert.IsFalse(result);

            contact = new Contact("Goran", 24, 1);
            result  = page.Validate(contact, validators);
            Assert.IsFalse(result);
        }
Пример #9
0
        public void ModuleFlightsTest()
        {
            TestPage    testPage    = new TestPage();
            FlightsPage flightsPage = new FlightsPage();

            flightsPage.StepNavigateToFlightsTab();
            testPage.StepHandleNewTab();
            flightsPage.StepNavigateToOneWay();
            flightsPage.StepNavigateToMultiCity();
            flightsPage.StepNavigateToRoundTrip();
            flightsPage.StepEnterFromWhere("Sarajevo");
            flightsPage.StepChooseFromDestination();
            flightsPage.StepEnterToWhere("Istanbul");
            flightsPage.StepChooseToDestination();
            flightsPage.StepChooseFromDate(DateTime.Today.AddDays(7).ToString("MMMM dd"));
            flightsPage.StepChooseToDate(DateTime.Today.AddDays(14).ToString("MMMM dd"));
            flightsPage.StepClickOnSearch();
        }
Пример #10
0
        public void OnPageExecuting_ToPage_SetsPropertyValue()
        {
            // Arrange
            var httpContext = new DefaultHttpContext();

            var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>())
            {
                { "TempDataProperty-Test", "Value" }
            };

            tempData.Save();

            var page = new TestPage()
            {
                ViewContext = CreateViewContext(httpContext, tempData)
            };

            var filter = CreatePageSaveTempDataPropertyFilter(tempData);

            filter.Subject = page;

            var pageType      = page.GetType();
            var testProperty  = pageType.GetProperty(nameof(TestPage.Test));
            var test2Property = pageType.GetProperty(nameof(TestPage.Test2));

            var context = new PageHandlerExecutingContext(
                new PageContext()
            {
                ActionDescriptor = new CompiledPageActionDescriptor(),
                HttpContext      = httpContext,
                RouteData        = new RouteData(),
            },
                Array.Empty <IFilterMetadata>(),
                null,
                new Dictionary <string, object>(),
                page);

            // Act
            filter.OnPageHandlerExecuting(context);

            // Assert
            Assert.Equal("Value", page.Test);
            Assert.Null(page.Test2);
        }
Пример #11
0
 public void ActivateTest()
 {
     TestPage samplePage = new TestPage();
     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);
         TestIPageView testPageView = samplePage.MyPageView as TestIPageView;
         Assert.AreEqual(hostingForm, testPageView.MyParent);
         Assert.AreEqual(Rectangle.FromLTRB(0, 0, 100, 100), testPageView.MyLocation);
         Assert.AreEqual(false, testPageView.IsVisible);
     }
 }
Пример #12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Do any additional setup after loading the view.
            // Initialize Xamarin.Forms framework
            global::Xamarin.Forms.Forms.Init();
            // Create an instance of XF page with associated View Model
            var xfPage = new TestPage();
            //var viewModel = (MainPageViewModel)xfPage.BindingContext;
            //viewModel.Message = "Welcome to XF Page created from an iOS Extension";
            // Override the behavior to complete the execution of the Extension when a user press the button
            //viewModel.DoCommand = new Command(() => DoneClicked(this));
            // Convert XF page to a native UIViewController which can be consumed by the iOS Extension
            var newController = xfPage.CreateViewController();

            // Present new view controller as a regular view controller
            this.PresentModalViewController(newController, false);
        }
Пример #13
0
        public void Resolve_CachePageStatePersister()
        {
            if (IoC.IsInitialized)
            {
                IoC.Reset();
            }

            IoC.InitializeWithEmptyContainer();
            IoC.Container.Register(Component
                                   .For <IServerPageStatePersister>()
                                   .ImplementedBy(typeof(SysCachePageStatePersister))
                                   .LifeStyle.Is(LifestyleType.Transient));

            var page      = new TestPage();
            var persister = ResolvePageStatePersister(page);

            Assert.IsNotNull(persister);
            Assert.IsInstanceOf <SysCachePageStatePersister>(persister);
        }
        public void DoubleTwoWayBindingWorks()
        {
            var page      = new TestPage();
            var viewModel = new ViewModel {
                Name = "Jason"
            };

            page.BindingContext = viewModel;

            page.ControlTemplate = new ControlTemplate(typeof(TestContent));
            page.SetBinding(TestPage.NameProperty, "Name");

            var entry = ((ContentView)((IElementController)page).LogicalChildren[0]).Content as Entry;

            ((IElementController)entry).SetValueFromRenderer(Entry.TextProperty, "Bar");
            viewModel.Name = "Raz";

            Assert.AreEqual("Raz", entry.Text);
        }
        public void Map_WhenGivenLinkMappingWithCustomResolver_ShouldReturnCorrectValue()
        {
            HalMapper.Instance.CreateMap <TestPage>() // Use custom resolver
            .ForLink("self").Use <HttpContextResolver>();

            // Create source object
            var source = new TestPage()
            {
                Name = "Test", Owner = new User()
                {
                    Id = "oveand", Name = "Ove Andersen"
                }
            };

            // Map source object
            var r = HalMapper.Instance.Map(source);

            // Assert
            Assert.AreEqual("/", r.Links["self"].Target.ToString());
        }
        public void Map_WhenGivenLinkMappingWithCustomResolverAndConstructorWithValidUri_ShouldReturnCorrectValue()
        {
            HalMapper.Instance.CreateMap <TestPage>() // Use custom resolver
            .ForLink("self").Use <StaticValueResolver>().ConstructedBy(() => new StaticValueResolver("/test"));

            // Create source object
            var source = new TestPage()
            {
                Name = "Test", Owner = new User()
                {
                    Id = "oveand", Name = "Ove Andersen"
                }
            };

            // Map source object
            var r = HalMapper.Instance.Map(source);

            // Assert
            Assert.AreEqual("/test", r.Links["self"].ToString());
        }
Пример #17
0
        public void FormsUpload_IsNotIndexed()
        {
            TestMedia media = Factory.GetMediaData("foo", "jpg");
            TestPage  page  = Factory.GetTestPage();

            Indexer.FormsUploadNamespace = "TestData.ITestPage";

            var assetHelperMock = new Mock <ContentAssetHelper>();

            assetHelperMock
            .Setup(m => m.GetAssetOwner(media.ContentLink))
            .Returns(page);

            _serviceLocationMock.ServiceLocatorMock.Setup(m => m.GetInstance <ContentAssetHelper>()).Returns(assetHelperMock.Object);


            IndexingStatus result = _indexer.Update(media);

            Assert.Equal(IndexingStatus.HideFromSearchProperty, result);
        }
Пример #18
0
 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 Map_WhenGivenLinkMappingWithStaticValue_ShouldReturnCorrectValue()
        {
            // Create map
            HalMapper.Instance.CreateMap <TestPage>()
            .ForLink("self").Use(new Uri("/pages/1", UriKind.Relative));

            // Create source object
            var source = new TestPage()
            {
                Name = "Test", Owner = new User()
                {
                    Id = "oveand", Name = "Ove Andersen"
                }
            };

            // Map source object
            var r = HalMapper.Instance.Map(source);

            // Assert
            Assert.AreEqual("/pages/1", r.Links["self"].Target.ToString());
        }
        public void Update()
        {
            lock (TestPage)
            {
                TestPage.Clear();
                TestPage.AddEntry("<h1> Video content delivery test: </h1><br>");
                TestPage.AddEntry("<br><iframe src=\"who.mp4\" width=\"100%\" height=\"300\" style=\"border:1px solid black;\">\r\n<br></iframe>");

                TestPage.AddEntry($"<br><br>It is {DateTime.Now}.");
                TestPage.AddEntry(
                    $"Thread pool threads: {ThreadPool.ThreadCount}, pending: {ThreadPool.PendingWorkItemCount}, completed: {ThreadPool.CompletedWorkItemCount}");
                if (PoemIndex < _poem.Length)
                {
                    TestPage.AddEntry(_poem[PoemIndex++]);
                }
                else
                {
                    PoemIndex = 0;
                }
            }
        }
        private void WebBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            HttpWebRequest req     = (HttpWebRequest)WebRequest.Create(webBrowser1.Url);
            var            cookies = new CookieContainer();

            req.CookieContainer = cookies;

            var clist       = cookies.GetCookies(webBrowser1.Document.Url);
            var pageCookies = new List <PageCookie>();

            foreach (Cookie cki in clist)
            {
                var pcki = new PageCookie()
                {
                    HttpOnly        = cki.HttpOnly,
                    IsSecure        = cki.Secure,
                    IsSessionCookie = cki.Discard,
                    LifeTime        = cki.Expires,
                    Name            = cki.Name
                };

                pageCookies.Add(pcki);
            }

            if (this.WebPageLoadCompleted != null)
            {
                var loadedPage = new TestPage(
                    webBrowser1.Url.ToString(),
                    webBrowser1.Url.ToString(),
                    webBrowser1.Document.Title,
                    this.IsLoginPage,
                    this.IsAuthenticatedPage,
                    pageCookies
                    );


                var eventArgs = new WebPageCompletedEventAgrs(loadedPage);
                this.WebPageLoadCompleted(this, eventArgs);
            }
        }
Пример #22
0
        // NOTE: BrowserKind argument must be first
        public async Task CanSendAndReceiveBytes(BrowserKind browserKind)
        {
            if (ShouldSkip(browserKind))
            {
                return;
            }

            var targetUri = new Uri(_apiServerFixture.RootUri, "/subdir/api/data");
            await TestPage.TypeAsync("#request-uri", targetUri.AbsoluteUri);

            await TestPage.ClickAsync("#send-request");

            var status = await TestPage.GetTextContentAsync("#response-status");

            var statusText = await TestPage.GetTextContentAsync("#response-status-text");

            var testOutcome = await TestPage.GetTextContentAsync("#test-outcome");

            Assert.Equal("OK", status);
            Assert.Equal("OK", statusText);
            Assert.Equal("", testOutcome);
        }
Пример #23
0
        public void OnTempDataSaving_PopulatesTempDataWithNewValuesFromPageProperties()
        {
            // Arrange
            var httpContext = new DefaultHttpContext();

            var tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());

            var page = new TestPage()
            {
                Test  = "TestString",
                Test2 = "Test2",
            };

            var filter = CreatePageSaveTempDataPropertyFilter(tempData);

            filter.Subject = page;

            var pageType = page.GetType();

            var testProperty  = pageType.GetProperty(nameof(TestPage.Test));
            var test2Property = pageType.GetProperty(nameof(TestPage.Test2));

            filter.OriginalValues[testProperty]  = "SomeValue";
            filter.OriginalValues[test2Property] = "Test2";

            filter.Properties = new List <TempDataProperty>
            {
                new TempDataProperty("TempDataProperty-Test", testProperty, testProperty.GetValue, testProperty.SetValue),
                new TempDataProperty("TempDataProperty-Test2", test2Property, test2Property.GetValue, test2Property.SetValue)
            };

            // Act
            filter.OnTempDataSaving(tempData);

            // Assert
            Assert.Equal("TestString", page.Test);
            Assert.Equal("TestString", tempData["TempDataProperty-Test"]);
            Assert.False(tempData.ContainsKey("TestDataProperty-Test2"));
        }
        public async Task InitializesViewModelOnLoadFailedTest()
        {
            NavigationManagerMock navigationManagerMock = new NavigationManagerMock();
            TestViewModel         viewModel             = new TestViewModel(navigationManagerMock);
            TestPage page = new TestPage
            {
                ViewModel         = viewModel,
                NavigationManager = navigationManagerMock,
            };

            viewModel.InitializeResult = false;

            await page.CallOnAfterRenderAsync(false);

            Assert.IsFalse(viewModel.WasInitializeCalled);
            Assert.IsTrue(page.IsLoading);

            await page.CallOnAfterRenderAsync(true);

            Assert.AreEqual(navigationManagerMock.NavigatedUri, "/");
            Assert.IsTrue(viewModel.WasInitializeCalled);
        }
Пример #25
0
        public void ModuleAirportTaxisTest()
        {
            TestPage         testPage         = new TestPage();
            AirportTaxisPage airportTaxisPage = new AirportTaxisPage();

            airportTaxisPage.StepNavigateToAirportTaxisTab();
            testPage.StepHandleNewTab();
            airportTaxisPage.StepEnterPickUpLocation("Istanbul");
            airportTaxisPage.StepChoosePickUpLocation();
            airportTaxisPage.StepEnterDropOffLocation("Blue Mosque");
            airportTaxisPage.StepChooseDropOffLocation();
            airportTaxisPage.StepClickOnSearch();
            airportTaxisPage.StepClickOnBookTaxi();
            airportTaxisPage.StepSelectTitle();
            airportTaxisPage.StepEnterFirstName("Amila");
            airportTaxisPage.StepEnterLastName("Zimic");
            airportTaxisPage.StepEnterEmail("*****@*****.**");
            airportTaxisPage.StepConfirmEmail("*****@*****.**");
            airportTaxisPage.StepChooseCountry();
            airportTaxisPage.StepEnterMobileNumber("62253119");
            airportTaxisPage.StepClickOnContinueToBook();
        }
Пример #26
0
        public async void StartAutoPageDisposal_ShouldDisposeWhenRemoved()
        {
            // creating the test page/viewmodel
            var page          = new TestPage();
            var testViewModel = new TestViewModel();

            page.BindingContext = testViewModel;

            // adding a main page to the navigation stack, because the root will not be popped
            var navigation = new AutoNavigationPage(new Page());
            //push the test page onto the navigation stack
            await navigation.PushAsync(page);

            //start the automatic disposal
            navigation.StartAutoPageDisposal();
            // remove the page
            navigation.Navigation.RemovePage(page);

            // Assert that both page and viewmodel called their Dispose methods.
            Assert.True(testViewModel.IsDisposed);
            Assert.True(page.IsDisposed);
        }
Пример #27
0
    public async Task CreateExecutor_ForVoidReturningMethod()
    {
        // Arrange
        var handler = new HandlerMethodDescriptor()
        {
            MethodInfo = typeof(TestPage).GetMethod(nameof(TestPage.VoidReturningHandler)),
            Parameters = new HandlerParameterDescriptor[0],
        };

        var page = new TestPage();

        // Act
        var executor = ExecutorFactory.CreateExecutor(handler);

        // Assert
        Assert.NotNull(executor);
        var actionResultTask = executor(page, null);
        var actionResult     = await actionResultTask;

        Assert.Null(actionResult);
        Assert.True(page.SideEffects);
    }
Пример #28
0
        public void FormsUpload_IsNotIndexed()
        {
            TestMedia media = Factory.GetMediaData("foo", "jpg");
            TestPage  page  = Factory.GetTestPage();

            var assetHelperMock = new Mock <ContentAssetHelper>();

            assetHelperMock
            .Setup(m => m.GetAssetOwner(media.ContentLink))
            .Returns(page);

            _indexer = new Indexer(
                _fixture.ServiceLocationMock.CoreIndexerMock.Object,
                _fixture.ServiceLocationMock.SettingsMock.Object,
                new Mock <ISiteDefinitionRepository>().Object,
                _fixture.ServiceLocationMock.ContentLoaderMock.Object,
                assetHelperMock.Object);

            IndexingStatus result = _indexer.Update(media);

            Assert.Equal(IndexingStatus.HideFromSearchProperty, result);
        }
Пример #29
0
        public App()
        {
            InitializeComponent();

            if (UseMockDataStore)
            {
                DependencyService.Register <MockDataStore>();
            }
            else
            {
                DependencyService.Register <CloudDataStore>();
            }

            if (Device.RuntimePlatform == Device.iOS)
            {
                MainPage = new TestPage();
            }
            else
            {
                MainPage = new NavigationPage(new TestPage());
            }
        }
Пример #30
0
        public static void ClassInitialize(TestContext context)
        {
            TestPage testPage0 = new TestPage
            {
                url         = @"http://rutor.is/torrent/541697/beloff-2019.2-minstall-vs-wpi-2019-pc-iso",
                description = @"<br><img src=""http://img15.lostpic.net/2019/01/02/12e0aa4792bfadadf135371c64e22316.jpg""><br>",
                spoilers    = 6,
                pic         = 1,
            };

            TestPage testPage1 = new TestPage
            {
                url         = @"http://rutor.is/torrent/315024/gimp-2.10.8-final-2019-rs",
                description = @"<img src=""http://i5.imageban.ru/out/2015/12/19/805d48652ce568b6b6f9262d5d54028c.jpg"" style=""float:right;"">",
                spoilers    = 3,
                pic         = 7,
            };

            testedNowPage = testPage0;

            preposts pr = new preposts
            {
                href = testedNowPage.url,
            };
            bool flagCall = false;

            item              = new RutorItem();
            item.OnPostMaked += delegate(object s, EventArgs e)
            {
                flagCall = true;
            };
            item.GetPost(pr);

            for (int callCount = 0; callCount < 48 && !flagCall; callCount++)
            {
                Thread.Sleep(250);
            }
        }
Пример #31
0
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            page      = e.NewElement as TestPage;
            activity  = this.Context as Activity;
            imageView = (ImageView)activity.FindViewById(Resource.Id.toolbar_logo);

            if (imageView != null)
            {
                var drawableImage = ContextCompat.GetDrawable(activity, Resources.GetIdentifier(page.Image, "drawable", activity.PackageName));
                var bitmap        = (drawableImage as BitmapDrawable).Bitmap;
                if (bitmap != null)
                {
                    imageView.SetImageBitmap(bitmap);
                }
            }
        }
        public async Task InitializesViewModelOnLoadSuccessTest()
        {
            Mock <TestPage> mockPage = new Mock <TestPage>();

            mockPage.Protected().Setup("NotifyStateChanged").Callback(() => { });
            NavigationManagerMock navigationManagerMock = new NavigationManagerMock();
            TestViewModel         viewModel             = new TestViewModel(navigationManagerMock);
            TestPage page = mockPage.Object;

            page.ViewModel             = viewModel;
            page.NavigationManager     = navigationManagerMock;
            viewModel.InitializeResult = true;

            await page.CallOnAfterRenderAsync(false);

            Assert.IsFalse(viewModel.WasInitializeCalled);
            Assert.IsTrue(page.IsLoading);

            await page.CallOnAfterRenderAsync(true);

            Assert.IsTrue(viewModel.WasInitializeCalled);
            Assert.IsFalse(page.IsLoading);
        }
 public void When_navigating_by_jquery()
 {
     _page = SUT.To <TestPage>(_jquerySelector);
 }
 public void When_navigating_via_mvc_controller()
 {
     _receivedPageObject = SUT.NavigateToInitialPage<TestController, TestPage>(_action, _routeValues);
 }
Пример #35
0
        public void EditPropertyTest()
        {
            TestPage testPage = new TestPage();

            testPage.EditProperty(0);
            // all we have to do is make sure this doesn't throw
        }
Пример #36
0
        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]);
        }
Пример #37
0
        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);
        }
Пример #38
0
        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);
            }
        }
Пример #39
0
		public void Test1 ()
		{
			var page = new TestPage ();
			
			page.DataSource = new SimpleDataSource ();
			page.Platform = new UnitPlatform();

			Assert.AreEqual (9, page.DataSource.MaskedKeys.Count ());
		}
Пример #40
0
		public void DoubleTwoWayBindingWorks ()
		{
			var page = new TestPage ();
			page.Platform = new UnitPlatform ();
			var viewModel = new ViewModel {
				Name = "Jason"
			};
			page.BindingContext = viewModel;

			page.ControlTemplate = new ControlTemplate (typeof (TestContent));
			page.SetBinding (TestPage.NameProperty, "Name");

			var entry = ((ContentView)page.LogicalChildren[0]).Content as Entry;
			((IElementController)entry).SetValueFromRenderer (Entry.TextProperty, "Bar");
			viewModel.Name = "Raz";

			Assert.AreEqual ("Raz", entry.Text);
		}
Пример #41
0
        public void TranslateAcceleratorTest()
        {
            TestPage testPage = new TestPage();
            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;
                pageView.sampleChildHwnd = new IntPtr(10);
                pageView.outLParam = new IntPtr(11);
                pageView.outWParam = new IntPtr(12);

                MSG[] recognizedAcceleratorMessage = new MSG[] { new MSG() };
                recognizedAcceleratorMessage[0].hwnd = pageView.sampleChildHwnd;
                recognizedAcceleratorMessage[0].message = 1;
                recognizedAcceleratorMessage[0].wParam = new IntPtr(2);
                recognizedAcceleratorMessage[0].lParam = new IntPtr(3);

                int hr = testPage.TranslateAccelerator(recognizedAcceleratorMessage);
                Assert.AreEqual(VSConstants.S_OK, hr);
                Assert.AreEqual(pageView.outLParam, recognizedAcceleratorMessage[0].lParam);
                Assert.AreEqual(pageView.outWParam, recognizedAcceleratorMessage[0].wParam);

                MSG[] unrecognizedAcceleratorMessage = new MSG[] { new MSG() };
                unrecognizedAcceleratorMessage[0].hwnd = new IntPtr(100);
                unrecognizedAcceleratorMessage[0].message = 1;
                unrecognizedAcceleratorMessage[0].wParam = new IntPtr(2);
                unrecognizedAcceleratorMessage[0].lParam = new IntPtr(3);

                hr = testPage.TranslateAccelerator(unrecognizedAcceleratorMessage);
                Assert.AreEqual(VSConstants.S_FALSE, hr);
                Assert.AreEqual(new IntPtr(2), unrecognizedAcceleratorMessage[0].wParam);
                Assert.AreEqual(new IntPtr(3), unrecognizedAcceleratorMessage[0].lParam);
            }
        }
Пример #42
0
 public void ShowTest()
 {
     TestPage testPage = new TestPage();
     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.IsFalse(pageView.IsVisible);
         testPage.Show(Constants.SW_SHOW);
         Assert.IsTrue(pageView.IsVisible);
         testPage.Show(Constants.SW_HIDE);
         Assert.IsFalse(pageView.IsVisible);
         testPage.Show(Constants.SW_SHOWNORMAL);
         Assert.IsTrue(pageView.IsVisible);
         testPage.Show(7);
         Assert.IsTrue(pageView.IsVisible);
     }
 }
Пример #43
0
 public void SetPageSiteTest()
 {
     TestPage testPage = new TestPage();
     Mocks.MockIPropertyPageSite mockSite = new PropertyPageBaseTest.Mocks.MockIPropertyPageSite();
     testPage.SetPageSite(mockSite);
     Assert.AreEqual(mockSite, testPage.IPropertyPageSite);
     Assert.IsNotNull(testPage.MyPageView);
 }
 public void When_navigating_via_url()
 {
     _receivedPageObject = SUT.NavigateToInitialPage<TestPage>(_url);
 }
Пример #45
0
 public void ConstructorTest()
 {
     TestPage samplePage = new TestPage();
     Assert.IsNotNull(samplePage);
 }
Пример #46
0
        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]);
        }
Пример #47
0
        public void MultipleSetObjectsCallsTest()
        {
            TestPage testPage = new TestPage();

            string dummyObject = "dummy";
            string dummyObject2 = "dummy2";

            testPage.SetObjects(1, new object[] { dummyObject });
            TestIPropertyStore testPropertyStore = testPage.IPropertyStore as TestIPropertyStore;
            Assert.AreEqual(dummyObject, testPropertyStore.ObjectSet);
            testPage.SetObjects(1, new object[] { dummyObject2 });

            testPropertyStore = testPage.IPropertyStore as TestIPropertyStore;
            Assert.AreEqual(dummyObject2, testPropertyStore.ObjectSet);
            Assert.IsTrue((testPage.MyPageView as TestIPageView).PropertiesRefreshed);
        }
Пример #48
0
        public void GetPageInfoTest()
        {
            TestPage testPage = new TestPage();

            PROPPAGEINFO[] pageInfoList = new PROPPAGEINFO[1];
            testPage.GetPageInfo(pageInfoList);

            PROPPAGEINFO testPageInfo = pageInfoList[0];

            Assert.AreEqual((uint)Marshal.SizeOf(typeof(PROPPAGEINFO)), testPageInfo.cb);
            Assert.AreEqual((uint)0, testPageInfo.dwHelpContext);
            Assert.IsNull(testPageInfo.pszHelpFile);
            Assert.IsNull(testPageInfo.pszDocString);
            Assert.AreEqual(testPage.MyPageView.ViewSize, new Size(testPageInfo.SIZE.cx, testPageInfo.SIZE.cy));
            Assert.AreEqual(testPage.Title, testPageInfo.pszTitle);
        }
Пример #49
0
        public void SetObjectsTest()
        {
            TestPage testPage = new TestPage();

            string dummyObject = "dummy";

            testPage.SetObjects(1, new object[] { dummyObject });
            TestIPropertyStore testPropertyStore = testPage.IPropertyStore as TestIPropertyStore;
            Assert.AreEqual(dummyObject, testPropertyStore.ObjectSet);
        }
Пример #50
0
        public void GetPropertyStoreTest()
        {
            TestPage testPage = new TestPage();
            testPage.GetRealStore = true;

            string propertyName = "Property1";
            string propertyValue = "Value1";

            TestIVsBrowseObject dataObject = new TestIVsBrowseObject();
            TestIVsHierarchy hierarchy = new TestIVsHierarchy();
            dataObject.Hierarchy = hierarchy;
            TestDTEProject dteProject = new TestDTEProject();
            hierarchy.dteProject = dteProject;
            TestDTEProperties dteProjectProperties = new TestDTEProperties();
            dteProject.ProjectProperties = dteProjectProperties;
            TestDTEProperty property1 = new TestDTEProperty();
            property1.PropertyValue = propertyValue;
            dteProjectProperties.Properties.Add(propertyName, property1);

            testPage.SetObjects(1, new object[] { dataObject });
            Assert.AreEqual(propertyValue, testPage.GetValueForProperty(propertyName));
        }
Пример #51
0
        public void GetValueForPropertyTest()
        {
            TestPage testPage = new TestPage();

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

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

            string actualValue = testPage.GetValueForProperty(propertyName);
            Assert.AreEqual(expectedValue, actualValue);
        }
Пример #52
0
 public void When_navigating_via_mvc_controller()
 {
     _receivedPageObject = SUT.NavigateToInitialPage <TestController, TestPage>(_action);
 }
Пример #53
0
 public App()
 {
     // The root page of your application
     MainPage = new TestPage();
 }