public void Create_description_for_item_due_over_a_week_ago()
        {
            var generator = new AtomFeedGenerator();
            var fixture   = new Fixture();
            var userFeed  = fixture.Create <UserFeed>();
            var items     = fixture.CreateMany <UserItem>(14);
            var dueDate   = DateTime.Today.AddDays(-7);

            foreach (var item in items)
            {
                item.PostponedUntilDate = null;
                item.NextDueDate        = dueDate;
                dueDate = dueDate.AddDays(-1);
            }
            var atomDoc = generator.GenerateFeed("https://smalllister.nosuchblogger.com", DateTime.UtcNow, items, userFeed);

            atomDoc.Should().NotBeNull();

            var atomXmlString = atomDoc.ToXmlString();

            Console.WriteLine(atomXmlString);
            atomXmlString.Should().Contain($"<id>https://smalllister.nosuchblogger.com/feed/{userFeed.UserFeedIdentifier}</id>");

            dueDate = DateTime.Today.AddDays(-7);
            foreach (var item in items)
            {
                atomXmlString.Should().Contain($"You have an overdue item! It was due on {dueDate.ToString("d MMM yyyy")}");
                dueDate = dueDate.AddDays(-1);
            }
        }
예제 #2
0
        public static async Task GenerateFeed()
        {
            using (var service = new FlightService())
            {
                var flights = await service.GetFlightsForAtom(50);

                var items = flights.Select(x => new AtomFeedItem()
                {
                    Id          = Guid.Parse(Md5(x.LogNumber)),
                    Link        = new Uri("http://services.sled.sc.gov/Aviation/CopViewPublic2.aspx?LOGID=" + x.LogNumber),
                    Summary     = BuildDescription(x),
                    Title       = "SLED Helicopter Flight " + x.LogNumber,
                    LastUpdated = x.CompletedAt,
                    AuthorName  = "South Carolina Law Enforcement Division",
                    Category    = $"Aircraft N{x.Aircraft}",
                }).ToList();

                var f = new AtomFeed()
                {
                    AuthorName  = "South Carolina Law Enforcement Division",
                    Id          = Guid.Parse("EFF7C905-20B3-49B7-9503-D67E181289A2"),
                    LastUpdated = DateTimeOffset.UtcNow,
                    Link        = new Uri("http://www.sled.sc.gov"),
                    //LinkSelf = new Uri("http://www.sled.sc.gov"),
                    Title = "South Carolina Law Enforcement Division Helicopter Flight Log",
                    Items = items
                };

                var feed = AtomFeedGenerator.GenerateFeed(f);

                await UploadFile("flights.xml", feed, "text/xml");
            }
        }
        public void Create_description_for_item_due_in_the_last_week()
        {
            var generator = new AtomFeedGenerator();
            var fixture   = new Fixture();
            var userFeed  = fixture.Create <UserFeed>();
            var items     = fixture.CreateMany <UserItem>(5); // will be "last <Day of week>" up to 6 days ago, except for yesterday which is a special case
            var dueDate   = DateTime.Today.AddDays(-2);

            foreach (var item in items)
            {
                item.PostponedUntilDate = null;
                item.NextDueDate        = dueDate;
                dueDate = dueDate.AddDays(-1);
            }
            var atomDoc = generator.GenerateFeed("https://smalllister.nosuchblogger.com", DateTime.UtcNow, items, userFeed);

            atomDoc.Should().NotBeNull();

            var atomXmlString = atomDoc.ToXmlString();

            Console.WriteLine(atomXmlString);
            atomXmlString.Should().Contain($"<id>https://smalllister.nosuchblogger.com/feed/{userFeed.UserFeedIdentifier}</id>");

            dueDate = DateTime.Today.AddDays(-2);
            foreach (var item in items)
            {
                atomXmlString.Should().Contain($"You have an overdue item! It was due last {dueDate.ToString("dddd")}");
                dueDate = dueDate.AddDays(-1);
            }
        }
        public void Generate_empty_feed()
        {
            var generator = new AtomFeedGenerator();
            var atomDoc   = generator.GenerateFeed("https://smalllister.nosuchblogger.com", DateTime.UtcNow, new List <UserItem>(), new UserFeed
            {
                UserFeedIdentifier = "mytestfeed"
            });

            atomDoc.Should().NotBeNull();

            var atomXmlString = atomDoc.ToXmlString();

            Console.WriteLine(atomXmlString);
            atomXmlString.Should().Contain("<id>https://smalllister.nosuchblogger.com/feed/mytestfeed</id>");
            atomXmlString.Should().NotContain("<entry>");
        }
        public void Generate_feed_entries()
        {
            var generator = new AtomFeedGenerator();
            var fixture   = new Fixture();
            var userFeed  = fixture.Create <UserFeed>();

            userFeed.ItemDisplay = UserFeedItemDisplay.Description;
            var items   = fixture.Build <UserItem>().CreateMany();
            var atomDoc = generator.GenerateFeed("https://smalllister.nosuchblogger.com", DateTime.UtcNow, items, userFeed);

            atomDoc.Should().NotBeNull();

            var atomXmlString = atomDoc.ToXmlString();

            Console.WriteLine(atomXmlString);
            atomXmlString.Should().Contain($"<id>https://smalllister.nosuchblogger.com/feed/{userFeed.UserFeedIdentifier}</id>");
            atomXmlString.Should().Contain("<entry>");
        }
        public void Create_description_for_item_postponed_until_yesterday()
        {
            var generator = new AtomFeedGenerator();
            var fixture   = new Fixture();
            var userFeed  = fixture.Create <UserFeed>();
            var item      = fixture.Create <UserItem>();

            item.PostponedUntilDate = DateTime.Today.AddDays(-1);
            item.NextDueDate        = DateTime.Today.AddDays(-10);
            var atomDoc = generator.GenerateFeed("https://smalllister.nosuchblogger.com", DateTime.UtcNow, new[] { item }, userFeed);

            atomDoc.Should().NotBeNull();

            var atomXmlString = atomDoc.ToXmlString();

            Console.WriteLine(atomXmlString);
            atomXmlString.Should().Contain($"<id>https://smalllister.nosuchblogger.com/feed/{userFeed.UserFeedIdentifier}</id>");
            atomXmlString.Should().Contain("You have an overdue item! It was due yesterday");
        }
예제 #7
0
        public static async Task RunSupreme()
        {
            var proxyHost = ConfigurationManager.AppSettings["Proxy.Host"];
            var proxyPort = ConfigurationManager.AppSettings["Proxy.Port"];
            var proxyUser = ConfigurationManager.AppSettings["Proxy.User"];
            var proxyPass = ConfigurationManager.AppSettings["Proxy.Pass"];

            var client   = new SupremeCourt(proxyHost, Convert.ToInt32(proxyPort), proxyUser, proxyPass);
            var opinions = await client.GetOpinions();

            Console.WriteLine("Got {0} opinions for Supreme.", opinions.Count);

            var items = opinions.Select(x => new AtomFeedItem()
            {
                Id          = Guid.Parse(x.Type == "order" ? Md5(x.Url) : Md5(x.Id)),
                Link        = new Uri(x.Url),
                Summary     = x.Description,
                Title       = x.Title,
                LastUpdated = x.Date,
                AuthorName  = "Supreme Court of South Carolina",
                Category    = x.Type,
            }).ToList();

            var f = new AtomFeed()
            {
                AuthorName  = "Supreme Court of South Carolina",
                Id          = Guid.Parse("062c1964-e9f2-ca37-8c51-6f4ed3e0cee1"),
                LastUpdated = DateTimeOffset.UtcNow,
                Link        = new Uri("http://www.sccourts.org/opinions/indexCOAPub.cfm"),
                //LinkSelf = new Uri("http://www.sccourts.org/opinions/indexCOAPub.cfm"),
                Title = "South Carolina Supreme Court Published Opinions",
                Items = items
            };

            var feed = AtomFeedGenerator.GenerateFeed(f);

            await UploadFile("supreme.xml", feed, "text/xml");
        }