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(); }
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); }
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); }
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); }