public void GetValidUrls_WhenShortUrlIsNotValidReturns_ListOfZero() { //Arrange var shortUrl = new ShortUrl { Id = 1, OriginalUrl = "Google.com", ShortenUrl = ShortUrlToBeTested, InsertDate = DateTime.Now.AddMonths(-4) }; _mockShortUrls.SetSource(new[] { shortUrl }); //Act var shortUrls = _shortUrlRepository.GetValidUrls(3); //Assert Assert.That(shortUrls.Count, Is.EqualTo(0)); }
public void GetValidUrls_WhenCalled_ReturnsValidOnly() { var shortUrlsList = new List <ShortUrl> { new ShortUrl() { OriginalUrl = "www.DeltaTre1.com", ShortenUrl = "12345678", InsertDate = DateTime.Now.AddMonths(-1) }, new ShortUrl() { OriginalUrl = "www.DeltaTre2.com", ShortenUrl = "12345677", InsertDate = DateTime.Now.AddMonths(-2) }, new ShortUrl() { OriginalUrl = "www.DeltaTre3.com", ShortenUrl = "12345676", InsertDate = DateTime.Now.AddMonths(-3) }, new ShortUrl() { OriginalUrl = "www.DeltaTre4.com", ShortenUrl = "12345675", InsertDate = DateTime.Now.AddMonths(-4) }, new ShortUrl() { OriginalUrl = "www.DeltaTre5.com", ShortenUrl = "12345674", InsertDate = DateTime.Now.AddMonths(-5) }, new ShortUrl() { OriginalUrl = "www.DeltaTre6.com", ShortenUrl = "12345673", InsertDate = DateTime.Now.AddMonths(-6) } }; _context.ShortUrls.AddRange(shortUrlsList); _context.SaveChanges(); var shortUrlRepository = new ShortUrlRepository(_context); var validUrl = shortUrlRepository.GetValidUrls(3).Count; Assert.That(validUrl, Is.EqualTo(3)); }