Beispiel #1
0
        public void TestGetTop3DocumentsByRatingWithOneDocuments()
        {
            Mock <ICommentRepository>  mockCommentRepository  = new Mock <ICommentRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();

            ITopsService topService = new TopsService
            {
                CommentRepository  = mockCommentRepository.Object,
                DocumentRepository = mockDocumentRepository.Object,
            };

            IEnumerable <Comment> fakeComments = GetFakeComment();

            Document fakeDocument0 = GetFakeDocument0();
            Document fakeDocument1 = GetFakeDocument1();

            mockCommentRepository
            .Setup(wl => wl.GetAll())
            .Returns(new List <Comment>()
            {
                fakeComments.ElementAt(3)
            });

            mockDocumentRepository
            .Setup(wl => wl.GetAll())
            .Returns(new List <Document>()
            {
                fakeDocument0
            });

            mockDocumentRepository
            .Setup(wl => wl.GetById(fakeDocument0.Id))
            .Returns(fakeDocument0);

            IEnumerable <Document> expected = new List <Document>()
            {
                fakeDocument0
            };

            IEnumerable <Document> results = topService.GetTop3DocumentsByRating();

            mockCommentRepository.VerifyAll();
            mockDocumentRepository.VerifyAll();

            Assert.IsNotNull(results);
            Assert.IsTrue(expected.SequenceEqual(results));
        }
Beispiel #2
0
        public void TestGetTop3DocumentsByRatingWithCeroDocuments()
        {
            Mock <ICommentRepository>  mockCommentRepository  = new Mock <ICommentRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();

            ITopsService topService = new TopsService
            {
                CommentRepository  = mockCommentRepository.Object,
                DocumentRepository = mockDocumentRepository.Object,
            };

            mockCommentRepository
            .Setup(wl => wl.GetAll())
            .Returns(new List <Comment>());

            IEnumerable <Document> results = topService.GetTop3DocumentsByRating();

            mockCommentRepository.VerifyAll();

            Assert.IsNotNull(results);
            Assert.IsTrue(results.Count() == 0);
        }