Esempio n. 1
0
    public void GoToPage(TPageType pageType)
    {
        if(_currentPageType == pageType) return; //we're already on the same page, so don't bother doing anything

        TPage pageToCreate = null;

        if(pageType == TPageType.PagePlayerSelect)
        {
            pageToCreate = new PlayerSelectPage();
        }
        else if (pageType == TPageType.PageInGame)
        {
            pageToCreate = new InGamePage();
        }
        else if (pageType == TPageType.PageResults)
        {
            pageToCreate = new PlayerSelectPage();
        }

        if(pageToCreate != null) //destroy the old page and create a new one
        {
            _currentPageType = pageType;

            if(_currentPage != null)
            {
                _currentPage.Destroy();
                _stage.RemoveChild(_currentPage);
            }

            _currentPage = pageToCreate;
            _stage.AddChild(_currentPage);
            _currentPage.Start();
        }
    }
Esempio n. 2
0
        /// <summary>
        /// Create the instance of page with access to page elements
        /// </summary>
        /// <typeparam name="TPageType">PageType</typeparam>
        public static TPageType Create <TPageType>() where TPageType : Page
        {
            TPageType instance = Activator.CreateInstance <TPageType>();

            new PageBuilder().Build(instance);
            return(instance);
        }
        /// <summary>
        /// Used when you want to manually navigate to a new page
        /// </summary>
        protected TPageType GoToPage <TPageType>() where TPageType : BasePage, new()
        {
            var page = new TPageType();

            page.SetLogger(Logger, Browser);
            var pageUrl = TestData.Get.GetUrl(page.UrlForPage);

            Browser.NavigateToUrl(pageUrl);
            return(page);
        }
Esempio n. 4
0
    public void SwapTeams()
    {
        if(_currentPageType == TPageType.PagePlayerSelect)
        {
            GameManager.instance.shouldUseTeams = !GameManager.instance.shouldUseTeams;
            GameManager.instance.RefreshPlayers();

            _currentPageType = TPageType.PageNone;
            GoToPage(TPageType.PagePlayerSelect);
        }
    }
        /// <summary>
        /// Used when you are redirected to a page
        /// </summary>
        protected TPageType GetPage <TPageType>() where TPageType : BasePage, new()
        {
            var page = new TPageType();

            page.SetLogger(Logger, Browser);

            Retry.Execute(Logger, () =>
            {
                var currentUrl = Browser.GetCurrentUrl();
                var pageUrl    = TestData.Get.GetUrl(page.UrlForPage);
                Assert.Equal(pageUrl.ToString(), currentUrl);
            });

            return(page);
        }