Exemple #1
0
        public void WillNotReturnUrlReturnedByWikiUrlFetchServiceIfUrlAlreadyVisited()
        {
            var user = TestableUser.Create();

            var category = new Category {
                Slug = "test"
            };

            var categoryUrl = new CategoryUrl {
                Url           = "url",
                DateRetrieved = DateTime.Now
            };

            var visit = new Visit {
                CategoryUrl = categoryUrl
            };

            user.WikiUrlFetchService.Setup(s => s.GetUrl(category))
            .Returns(new[] { categoryUrl });
            user.Visits.Add(visit);

            var url = user.GetNextVisit(category);

            Assert.Null(url);
        }
Exemple #2
0
        public void ThrowsExceptionWithNullCategory()
        {
            var user = TestableUser.Create();

            var ex = Assert.Throws <ArgumentException>(() => user.GetNextVisit(null));

            Assert.Equal("category", ex.ParamName);
        }
Exemple #3
0
        public void WillReturnNullUrlIfWikiUrlFetchServiceDoesNotReturnAnyUrl()
        {
            var user = TestableUser.Create();

            var category = new Category {
                Slug = "test"
            };

            user.WikiUrlFetchService.Setup(s => s.GetUrl(category))
            .Returns(new CategoryUrl[] { })
            .Verifiable();

            var url = user.GetNextVisit(category);

            user.WikiUrlFetchService.Verify();
            Assert.Null(url);
        }
Exemple #4
0
        public void WillReturnUrlReturnedByWikiUrlFetchServiceIfUrlNotAlreadyVisited()
        {
            var user = TestableUser.Create();

            var category = new Category {
                Slug = "test"
            };

            var categoryUrl = new CategoryUrl {
                Url           = "url",
                DateRetrieved = DateTime.Now
            };

            user.WikiUrlFetchService.Setup(s => s.GetUrl(category))
            .Returns(new[] { categoryUrl });

            var url = user.GetNextVisit(category);

            Assert.True(user.Visits.Any(v => v.CategoryUrl == categoryUrl));
            Assert.Same(categoryUrl, url);
        }
Exemple #5
0
        public void WillCallWikiUrlFetchServiceToGetUrlForAGivenCategory()
        {
            var user = TestableUser.Create();

            var category = new Category {
                Slug = "test"
            };

            var categoryUrl = new CategoryUrl {
                Url           = "url",
                DateRetrieved = DateTime.Now
            };

            user.WikiUrlFetchService.Setup(s => s.GetUrl(category))
            .Returns(new[] { categoryUrl })
            .Verifiable();

            var url = user.GetNextVisit(category);

            user.WikiUrlFetchService.Verify();
        }
Exemple #6
0
        public void WillNotReturnSameUrlWhenCalledTwiceEvenIfWikiUrlFetchServiceHasOnlyOneUrlAvailable()
        {
            var user = TestableUser.Create();

            var category = new Category {
                Slug = "test"
            };

            var categoryUrl = new CategoryUrl {
                Url           = "url",
                DateRetrieved = DateTime.Now
            };

            user.WikiUrlFetchService.Setup(s => s.GetUrl(category))
            .Returns(new[] { categoryUrl });

            var url1 = user.GetNextVisit(category);

            var url2 = user.GetNextVisit(category);

            Assert.NotNull(url1);
            Assert.Null(url2);
        }