public void LoadCommandCantBeExecutedDuringLoading()
 {
     Mock<IWebService> mock = new Mock<IWebService>();
     mock.Setup(e => e.DownloadItems(It.IsAny<string>())).Returns(() =>
     {
         return new Task<ZumpaReader.WebService.WebService.ContextResult<ZumpaItemsResult>>(() => null);
     });
     LoadMainPageCommand lc = new LoadMainPageCommand(mock.Object, (e) => {});
     lc.Execute(null);
     Assert.IsFalse(lc.CanExecute(null));
 }
 public void LoadCommandCallDownloadItemsWithParam()
 {
     string url = "http://test.com";
     Mock<IWebService> mock = new Mock<IWebService>();
     mock.Setup(e => e.DownloadItems(It.IsAny<string>())).Returns(() =>
     {
         return new Task<ZumpaReader.WebService.WebService.ContextResult<ZumpaItemsResult>>(() => null);
     }).Verifiable();
     LoadMainPageCommand lc = new LoadMainPageCommand(mock.Object, (e) => { });
     lc.LoadURL = url;
     lc.Execute(null);
     mock.Verify( e=> e.DownloadItems(url));
 }
        public override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            (Page.ApplicationBar.Buttons[ADD_INDEX] as ApplicationBarIconButton).IsEnabled = AppSettings.IsLoggedIn;

            _client = HttpService.CreateInstance();

            SwitchFavoriteThreadCommand = new Commands.SwitchFavoriteThreadCommand(_client);
            SwitchFavoriteThreadCommand.CanExecuteChanged += (o,e1) => { IsProgressVisible = !SwitchFavoriteThreadCommand.CanExecuteIt;};

            LoadCommand = new LoadMainPageCommand(_client, (ea) => Dispatcher.BeginInvoke(() => OnDownloadedPage(ea.Context)));
            LoadCommand.CanExecuteChanged += (o, ea) =>
            {
                bool can = LoadCommand.CanExecute(null);
                IsProgressVisible = !can;
                (Page.ApplicationBar.Buttons[RELOAD_INDEX] as ApplicationBarIconButton).IsEnabled = can;
            };
            if (e.NavigationMode == System.Windows.Navigation.NavigationMode.New)
            {
                LoadCommand.Execute(null);
            }
        }
 public void LoadCommandCanBeExecutedOnStart()
 {
     Mock<IWebService> mock = new Mock<IWebService>();
     LoadMainPageCommand lc = new LoadMainPageCommand(mock.Object, null);
     Assert.IsTrue(lc.CanExecute(null));
 }