Example #1
0
 public async void ShouldCheckStarredAndWatchedStatusOnRefresh()
 {
     var vm = new RepositoryViewModel(Owner, Repo);
     GitHubClientMock.Verify(m => m.Activity.Starring.CheckStarred(Owner, Repo), Times.Once());
     GitHubClientMock.Verify(m => m.Activity.Watching.CheckWatched(Owner, Repo), Times.Once());
     
     // should also check on refresh
     await vm.Refresh();
     GitHubClientMock.Verify(m => m.Activity.Starring.CheckStarred(Owner, Repo), Times.Exactly(2));
     GitHubClientMock.Verify(m => m.Activity.Watching.CheckWatched(Owner, Repo), Times.Exactly(2));
 }
Example #2
0
        public async void RepoVMShouldRefreshChildVMs()
        {
            var vm = new RepositoryViewModel(Owner, Repo);

            var prsMock = new Mock<RepositoryPullRequestsViewModel>(Owner, Repo);
            var issuesMock = new Mock<RepositoryIssuesViewModel>(Owner, Repo);
            var commitsMock = new Mock<RepositoryCommitsViewModel>(Owner, Repo);
            prsMock.Setup(m => m.Refresh()).Returns(() => Task.Run(() => { }));
            issuesMock.Setup(m => m.Refresh()).Returns(() => Task.Run(() => { }));
            commitsMock.Setup(m => m.Refresh()).Returns(() => Task.Run(() => { }));

            vm.IssuesViewModel = issuesMock.Object;
            vm.PullRequestsViewModel = prsMock.Object;
            vm.CommitsViewModel = commitsMock.Object;
            await vm.Refresh();

            prsMock.Verify(m => m.Refresh(), Times.Once());
            prsMock.Verify(m => m.Refresh(), Times.Once());
            prsMock.Verify(m => m.Refresh(), Times.Once());
        }
Example #3
0
        public async void TestStarringToggleCommand()
        {
            GitHubClientMock.Setup(m => m.Activity.Starring.StarRepo(Owner, Repo)).Returns(() => Task.FromResult(true));
            GitHubClientMock.Setup(m => m.Activity.Starring.RemoveStarFromRepo(Owner, Repo)).Returns(() => Task.FromResult(true));

            // should star when un-starred (if that's a word)
            GitHubClientMock.Setup(m => m.Activity.Starring.CheckStarred(Owner, Repo)).Returns(() => Task.FromResult(false));

            var vm = new RepositoryViewModel(Owner, Repo);
            Assert.AreEqual(false, vm.IsStarred);
            await vm.ToggleStarred.Execute();
            GitHubClientMock.Verify(m => m.Activity.Starring.StarRepo(Owner,Repo), Times.Once());

            // should un-star when starred
            GitHubClientMock.Setup(m => m.Activity.Starring.CheckStarred(Owner, Repo)).Returns(() => Task.FromResult(true));

            vm = new RepositoryViewModel(Owner, Repo);
            Assert.AreEqual(true, vm.IsStarred);
            await vm.ToggleStarred.Execute();
            GitHubClientMock.Verify(m => m.Activity.Starring.RemoveStarFromRepo(Owner, Repo), Times.Once());
        }
Example #4
0
        public async void TestWatchingToggleCommand()
        {
            GitHubClientMock.Setup(m => m.Activity.Watching.WatchRepo(Owner, Repo, It.IsAny<NewSubscription>())).Returns(() => Task.FromResult(new Subscription()));
            GitHubClientMock.Setup(m => m.Activity.Watching.UnwatchRepo(Owner, Repo)).Returns(() => Task.FromResult(true));

            // should watch when not watched
            GitHubClientMock.Setup(m => m.Activity.Watching.CheckWatched(Owner, Repo)).Returns(() => Task.FromResult(false));

            var vm = new RepositoryViewModel(Owner, Repo);
            Assert.AreEqual(false, vm.IsWatched);
            await vm.ToggleWatch.Execute();
            GitHubClientMock.Verify(m => m.Activity.Watching.WatchRepo(Owner, Repo, It.IsAny<NewSubscription>()), Times.Once());

            // should un-watch when watched
            GitHubClientMock.Setup(m => m.Activity.Watching.CheckWatched(Owner, Repo)).Returns(() => Task.FromResult(true));

            vm = new RepositoryViewModel(Owner, Repo);
            Assert.AreEqual(true, vm.IsWatched);
            await vm.ToggleWatch.Execute();
            GitHubClientMock.Verify(m => m.Activity.Watching.UnwatchRepo(Owner, Repo), Times.Once());
        }