Пример #1
0
        public async void IssuesVMShouldGetAssignedAndSubscribed()
        {
            int i = 0;
            GitHubClientMock.Setup(m => m.Issue.GetAllForCurrent(It.IsAny<IssueRequest>()))
                .Returns(() =>
                {
                    var issue = new Mock<Issue>();
                    issue.SetupProperty(x => x.HtmlUrl, new Uri(string.Format("http://www.google.com/{0}", i++)));
                    return Task.FromResult(new List<Issue>
                    {
                        issue.Object
                    } as IReadOnlyList<Issue>);
                });

            var vm = new UserIssuesViewModel();
            await vm.Refresh();
            GitHubClientMock.Verify(m => m.Issue.GetAllForCurrent(It.Is<IssueRequest>(r => r.Filter == IssueFilter.Assigned)), Times.Once());
            GitHubClientMock.Verify(m => m.Issue.GetAllForCurrent(It.Is<IssueRequest>(r => r.Filter == IssueFilter.Subscribed)), Times.Once());
            Assert.AreEqual(1, vm.AssignedIssues.Count);
            Assert.AreEqual(1, vm.SubscribedIssues.Count);
        }
Пример #2
0
        public async void SubscribedIssuesShouldNotIncludeAssigned()
        {
            var issue = new Mock<Issue>();
            issue.SetupProperty(i => i.HtmlUrl, new Uri("http://www.google.com"));
            GitHubClientMock.Setup(m => m.Issue.GetAllForCurrent(It.IsAny<IssueRequest>()))
                .Returns(() => Task.FromResult(new List<Issue>{ issue.Object } as IReadOnlyList<Issue>));

            var vm = new UserIssuesViewModel();
            await vm.Refresh();
            Assert.AreEqual(1, vm.AssignedIssues.Count);
            Assert.AreEqual(0, vm.SubscribedIssues.Count);
        }
Пример #3
0
        public async void SubscribedIssuesShouldNotIncludeAssigned()
        {
            var issue = new Issue(null, null, new Uri("http://www.google.com"), 1, ItemState.All, null, null, null, null, null, null, 0, null, null, DateTimeOffset.UtcNow, null);
            GitHubClientMock.Setup(m => m.Issue.GetAllForCurrent(It.IsAny<IssueRequest>()))
                .Returns(() => Task.FromResult(new List<Issue>{ issue } as IReadOnlyList<Issue>));

            var vm = new UserIssuesViewModel();
            await vm.Refresh();
            Assert.AreEqual(1, vm.AssignedIssues.Count);
            Assert.AreEqual(0, vm.SubscribedIssues.Count);
        }