public async void RefreshShouldRefreshChildViewModels() { var main = new MainViewModel(); var newsMock = new Mock<NewsViewModel>(); var issuesMock = new Mock<UserIssuesViewModel>(); var notificationsMock = new Mock<NotificationsViewModel>(); var reposMock = new Mock<UserRepositoriesViewModel>(); newsMock.Setup(m => m.Refresh()).Returns(Task.Run(() => { })); issuesMock.Setup(m => m.Refresh()).Returns(Task.Run(() => { })); notificationsMock.Setup(m => m.Refresh()).Returns(Task.Run(() => { })); reposMock.Setup(m => m.Refresh()).Returns(Task.Run(() => { })); main.NewsViewModel = newsMock.Object; main.IssuesViewModel = issuesMock.Object; main.NotificationsViewModel = notificationsMock.Object; main.ReposViewModel = reposMock.Object; await main.Refresh(); newsMock.Verify(m => m.Refresh(), Times.Once()); issuesMock.Verify(m => m.Refresh(), Times.Once()); notificationsMock.Verify(m => m.Refresh(), Times.Once()); reposMock.Verify(m => m.Refresh(), Times.Once()); }
public async void NavigationCommandsShouldCallNavigationService() { var vm = new MainViewModel(); await vm.GoToSearch.Execute(); MockNavigationService.Verify(ns => ns.Navigate(typeof(SearchPage), null), Times.Once()); await vm.GoToUserDetails.Execute(); MockNavigationService.Verify(ns => ns.Navigate(typeof(UserDetailsPage), null), Times.Once()); await vm.Logout.Execute(); MockNavigationService.Verify(ns => ns.Navigate(typeof(LoginPage), null), Times.Once()); }
public async void ShouldGetCurrentUserOnLoad() { var vm = new MainViewModel(); // once in main vm, once in notifications vm GitHubClientMock.Verify(m => m.User.Current(), Times.Exactly(2)); }