private void LoadViewModel() { if (_viewModel != null) { return; } _viewModel = new PostListViewModel(_showLater); BindingContext = _viewModel; _viewModel.LoadData(); }
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)); }
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)); }
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(); }
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); }