Example #1
0
        public void InvokeGoHome()
        {
            var view      = new MockBrowserView();
            var history   = new MockHistory();
            var favorites = new MockFavorites();
            var config    = new MockConfig();
            var presenter = new BrowserPresenter <MockTabPresenter>(
                view,
                history,
                favorites,
                config,
                new MockFaviconCache(),
                (tab, f, c, favicons, h, tabHistory) => new MockTabPresenter(tab, f, c, favicons, h, tabHistory));

            var url  = Url.FromString("www.myfavorite.com");
            var url2 = Url.FromString("www.myfavorite2.com");

            favorites.GetOrCreate(url);
            favorites.GetOrCreate(url2);
            view.InvokeFavoritesListOpen(0);
            view.InvokeFavoritesListOpen(1);

            view.InvokeFavoritesListOpen(0);

            Assert.AreEqual(history.GetViewModel()[history.GetViewModel().Count - 1].GetUrl(), url);

            view.InvokeGoHome();

            Assert.AreEqual(history.GetViewModel()[history.GetViewModel().Count - 1].GetUrl(), config.Home);
        }
Example #2
0
        public void InvokeNewIncognitoTab()
        {
            var history   = new MockHistory();
            var favorites = new MockFavorites();
            var view      = new MockBrowserView();
            var presenter = new BrowserPresenter <MockTabPresenter>(
                view,
                history,
                favorites,
                new MockConfig(),
                new MockFaviconCache(),
                (tab, f, c, favicons, h, tabHistory) => new MockTabPresenter(tab, f, c, favicons, h, tabHistory));

            var url  = Url.FromString("www.myfavorite.com");
            var url2 = Url.FromString("www.myfavorite2.com");

            favorites.GetOrCreate(url);
            favorites.GetOrCreate(url2);
            view.InvokeFavoritesListOpen(0);
            view.InvokeFavoritesListOpen(1);

            // open and switch to an incognito tab
            view.InvokeNewIncognitoTab();

            var list = history.GetViewModel().Count;

            view.InvokeFavoritesListOpen(0);
            Assert.AreEqual(list, history.GetViewModel().Count);
        }
        public void InvokeDeleteTest()
        {
            var win = new MockFavoritesView();
            var fav = new MockFavorites();
            var url = Url.FromString("Test");
            EditFavoritesPresenter pres = new EditFavoritesPresenter(win, url, fav);

            win.InvokeDeletePage();

            Assert.AreEqual(0, fav.GetViewModel().Count);
        }
        public void InvokeCancelTest()
        {
            var win = new MockFavoritesView();
            var fav = new MockFavorites();
            var url = Url.FromString("Test");
            EditFavoritesPresenter pres = new EditFavoritesPresenter(win, url, fav);

            win.InvokeCancelPage();

            Assert.AreEqual(fav.GetViewModel().Count, 1);
            Assert.AreEqual(fav.GetViewModel().Single(obj => obj.Url == url.ToString()).Url, url.ToString());
        }
        public void InvokeSaveTest()
        {
            var win = new MockFavoritesView();
            var fav = new MockFavorites();
            var url = Url.FromString("Test");
            EditFavoritesPresenter pres = new EditFavoritesPresenter(win, url, fav);

            win.InvokeSavePage();

            Assert.AreEqual(fav.GetViewModel().Count, 1);
            Assert.IsNotNull(fav.GetViewModel().SingleOrDefault(
                                 obj => obj.Url == Url.FromString("www.updatedurl.com").ToString()));
        }
Example #6
0
        public void InvokeAddFavoriteTest()
        {
            var favorites = new MockFavorites();

            var view      = new MockTabView();
            var presenter = new TabPresenter(
                view,
                favorites,
                new MockConfig(),
                new MockFaviconCache(),
                new MockHistory(),
                new MockTabHistory());

            var url = Url.FromString("www.test.com");

            presenter.Push(url);
            view.InvokeAddFavorite();
            Assert.IsNotNull(favorites.GetViewModel().Single(model => model.Url == url.ToString()));
        }
Example #7
0
        public void InvokeFavoritesListOpen()
        {
            var config    = new MockConfig();
            var favorites = new MockFavorites();
            var view      = new MockBrowserView();
            var presenter = new BrowserPresenter <MockTabPresenter>(
                view,
                new MockHistory(),
                favorites,
                config,
                new MockFaviconCache(),
                (tab, f, c, favicons, history, tabHistory) => new MockTabPresenter(tab, f, c, favicons, history, tabHistory));

            favorites.GetOrCreate(Url.FromString("www.myfavorite.com"));
            view.InvokeFavoritesListOpen(0);

            // easiest way to check if the url has changed
            var oldHome = config.Home;

            view.InvokeHomeChanged();
            Assert.AreNotEqual(oldHome, config.Home);
        }
Example #8
0
        public void InvokeHistoryListOpen()
        {
            var config    = new MockConfig();
            var favorites = new MockFavorites();
            var view      = new MockBrowserView();
            var presenter = new BrowserPresenter <MockTabPresenter>(
                view,
                new MockHistory(),
                favorites,
                config,
                new MockFaviconCache(),
                (tab, f, c, favicons, history, tabHistory) => new MockTabPresenter(tab, f, c, favicons, history, tabHistory));

            var url  = Url.FromString("www.myfavorite.com");
            var url2 = Url.FromString("www.myfavorite2.com");

            favorites.GetOrCreate(url);
            favorites.GetOrCreate(url2);
            view.InvokeFavoritesListOpen(0);
            view.InvokeFavoritesListOpen(1);

            // 0 - mock.com
            // 1 - url
            // 2 - url2

            view.InvokeHistoryListOpen(1);

            // easiest way to check if the url has changed
            view.InvokeHomeChanged();
            Assert.AreEqual(url, config.Home);

            view.InvokeHistoryListOpen(2);

            // easiest way to check if the url has changed
            view.InvokeHomeChanged();
            Assert.AreEqual(url2, config.Home);
        }