예제 #1
0
        private void LoadViewModel()
        {
            if (_viewModel != null)
            {
                return;
            }

            _viewModel     = new PostListViewModel(_showLater);
            BindingContext = _viewModel;
            _viewModel.LoadData();
        }
예제 #2
0
        public void LoadDataProgressBarCallsSuccessTest()
        {
            var viewModel = new PostListViewModel(null,
                                                  postSummaryServiceClientMock.Object,
                                                  windowManagerMock.Object,
                                                  progressBarMock.Object,
                                                  null);

            viewModel.LoadData(null);

            progressBarMock.Verify(x => x.Show(), Times.Exactly(1));
        }
예제 #3
0
        public void LoadDataThrowExceptionSuccessTest()
        {
            var viewModel = new PostListViewModel(null,
                                                  postSummaryServiceClientMock.Object,
                                                  windowManagerMock.Object,
                                                  progressBarMock.Object,
                                                  null);

            postSummaryServiceClientMock.Setup(x => x.Get(It.IsAny <string>())).Throws(new ConnectionTimeoutException());

            viewModel.LoadData(null);

            windowManagerMock.Verify(x => x.ShowDialog(It.IsAny <object>(), null, null), Times.Exactly(1));
        }
예제 #4
0
        private void ButtonShow_Clicked(object sender, EventArgs e)
        {
            if (!_showLater)
            {
                _showLater           = true;
                this.ButtonShow.Text = "Show all";
            }
            else
            {
                _showLater           = false;
                this.ButtonShow.Text = "Show post saved";
            }

            _viewModel.ShowSaveForLater = _showLater;
            _viewModel.LoadData();
        }
예제 #5
0
        public void LoadDataSuccessTest()
        {
            postSummaryServiceClientMock.Setup(summariesService => summariesService.Get(It.IsAny <string>())).Returns(() =>
            {
                var task = new Task <List <PostSummary> >(() => postSummaries);

                task.Start();
                task.Wait();
                return(task);
            });

            var viewModel = new PostListViewModel(null,
                                                  postSummaryServiceClientMock.Object,
                                                  windowManagerMock.Object,
                                                  progressBarMock.Object,
                                                  null);

            viewModel.LoadData(null);

            Assert.AreNotEqual(null, viewModel.PostSummaries);
            Assert.AreEqual(postSummaries.Count, viewModel.PostSummaries.Count);
        }