public Comic GetLastImportedComic(ComicType type) { return _context.Comics .Where(c => c.ComicType == type) .OrderByDescending(c => c.PublishedDate) .FirstOrDefault(); }
public void ItSendsBackSomeRss(ComicType type) { var mocker = new AutoMoqer(); mocker.GetMock<IComicsRepository>() .Setup(m => m.GetLatestComics(type, 10)) .Returns(new[] { new Comic() { ComicNumber = 1, ComicType = type, ImageSrc = "http://example.com/image.png", Permalink = "http://example.com", ComicId = 1, PublishedDate = DateTime.Today } }); var result = mocker.Create<FeedController>().Feed(type); var s = new MemoryStream(); result.FileStream.CopyTo(s); var xml = Encoding.UTF8.GetString(s.ToArray()); Check.That(result.ContentType).IsEqualTo("text/xml"); Check.That(xml).Contains("http://example.com/image.png"); }
public IReadOnlyCollection<Comic> GetLatestComics(ComicType type, int count = 10) { return _context.Comics .Where(c => c.ComicType == type) .OrderByDescending(c => c.PublishedDate) .Take(count) .ToList(); }
private Comic RegisterComic(ComicType type) { var comic = new Comic() { ComicType = type }; _mocker.GetMock<IComicsRepository>() .Setup(m => m.GetLastImportedComic(type)) .Returns(comic); _registry.Add(new ComicConfig(type, null)); return comic; }
public void ItSearchesForTheReferencedComic(ComicType type) { var mocker = new AutoMoqer(); mocker.GetMock<IComicsRepository>() .Setup(m => m.GetLatestComics(type, It.IsAny<int>())) .Returns(Enumerable.Empty<Comic>().ToList()) .Verifiable(); mocker.Create<FeedController>().Feed(type); mocker.GetMock<IComicsRepository>().Verify(); }
public ComicConfig(ComicType comicType, IComicDownloader downloader) { ComicType = comicType; Downloader = downloader; }