Пример #1
0
 /// <summary>
 /// Maintenance loop
 /// </summary>
 public async Task Maintenance()
 {
     Trace.WriteLine("InsomniaDaemon - Maintenance");
     // wrap maintenance so it won't prevent us from going on
     try
     {
         // We will run news service around every 15 mins
         NewsService ns = NewsService.Instance;
         if (DateTime.UtcNow.Subtract(ns.LastSuccess()).TotalMinutes > NEWS_UPDATE_INTERVAL_IN_MINUTES)
         {
             await ns.RunAsync();
         }
         // We will run funny service around once per hour
         FunnyService fs = FunnyService.Instance;
         if (DateTime.UtcNow.Subtract(fs.LastSuccess()).TotalMinutes > FUNNY_UPDATE_INTERVAL_IN_MINUTES)
         {
             await fs.RunAsync();
         }
     }
     catch (Exception e)
     {
         Trace.WriteLine("InsomniaDeamon - Maintenance - Fatal exception: " + e.Message);
     }
     if (!isJobScheduled())
     {
         scheduleJob();
     }
 }
Пример #2
0
        public void fetchPosts()
        {
            FunnyService fs  = FunnyService.Instance;
            List <Post>  fps = fs.fetchPosts().Result;

            Assert.AreNotEqual(0, fps.Count);
        }
Пример #3
0
 public void IsPictureLink()
 {
     Assert.IsTrue(FunnyService.isPictureLink("http://kfodksf/something.jpg"));
     Assert.IsTrue(FunnyService.isPictureLink("http://www.plaa.com/something.jpeg"));
     Assert.IsTrue(FunnyService.isPictureLink("http://db.some.fi/plaa/something.png"));
     Assert.IsTrue(FunnyService.isPictureLink("http://something.gif"));
     Assert.IsFalse(FunnyService.isPictureLink("https://www.something.com/4543453"));
     Assert.IsFalse(FunnyService.isPictureLink("http://wwww.reddit/r/doesnotexist/dfasff324324234fasdf"));
     Assert.IsFalse(FunnyService.isPictureLink("http://imgur.com/gallery/2GfQtZ0"));
     Assert.IsFalse(FunnyService.isPictureLink("https://www.google.com/maps/@38.921194,-77.041887,3a,75y,82.02h,79.5t/data=!3m5!1e1!3m3!1sIdCmgjET_rtLHHlpFFFryw!2e0!3e2"));
 }
Пример #4
0
        public void CreatePictureLink()
        {
            string ok = FunnyService.createPictureLink("http://anttieskola.azurewebsites.net/Images/mcsd.png").Result;

            Assert.AreNotEqual(null, ok);

            string notOk = FunnyService.createPictureLink("http://anttieskola.azurewebsites.net/Images/mcsd.fpokepwof").Result;

            Assert.AreEqual(null, notOk);

            string imgurOk = FunnyService.createPictureLink("http://imgur.com/UD5PpJs").Result;

            Assert.AreNotEqual(null, imgurOk);
        }
Пример #5
0
 public void IsPictureLinkNull()
 {
     Assert.IsFalse(FunnyService.isPictureLink(null));
 }