示例#1
0
        public void GetAllVotableIssuesSortedByDate_returns_empty_if_no_issues_are_found()
        {
            // Arrange
            IssueRepository mockRepo =
                Mock.Of <IssueRepository>(r => r.GetAllVotableIssues() == new List <Issue>());

            // Act
            var result = mockRepo.GetAllVotableIssuesSortedByDate();

            // Assert
            Assert.IsTrue(result.Count == 0);
        }
示例#2
0
        public void GetAllVotableIssuesSortedByDate_returns_sorted_list_of_votable_issues()
        {
            // Arrange
            var firstIssue  = Mock.Of <Issue>(i => i.CreatedAt == DateTime.Now.AddHours(2));
            var secondIssue = Mock.Of <Issue>(i => i.CreatedAt == DateTime.Now.AddHours(1));
            var thirdIssue  = Mock.Of <Issue>(i => i.CreatedAt == DateTime.Now);

            List <Issue> issues = new List <Issue>()
            {
                firstIssue,
                thirdIssue,
                secondIssue
            };

            IssueRepository mockRepo = Mock.Of <IssueRepository>(r => r.GetAllVotableIssues() == issues);

            // Act
            var result = mockRepo.GetAllVotableIssuesSortedByDate();

            // Assert
            Assert.AreEqual(firstIssue, result[0]);
            Assert.AreEqual(secondIssue, result[1]);
            Assert.AreEqual(thirdIssue, result[2]);
        }