public void WhenAnEntryIsAddedToTheFeedTheUpdatedElementOnTheFeedShouldBeUpdated() { RecentEventsFeed feed = new RecentEventsFeedBuilder().Build(); DateTimeOffset initialDateTime = feed.GetSyndicationFeed().LastUpdatedTime; Thread.Sleep(1000); feed.AddEvent(new EventBuilder().Build()); DateTimeOffset latestDateTime = feed.GetSyndicationFeed().LastUpdatedTime; Assert.Greater(latestDateTime, initialDateTime); }
public void ShouldCreateSyndicationFeed() { DateTimeOffset now = DateTime.Now; RecentEventsFeed recentEventsFeed = new RecentEventsFeedBuilder().WithId(2).WithPreviousId(1).WithUris(SampleLinks.Instance).Build(); SyndicationFeed syndicationFeed = recentEventsFeed.GetSyndicationFeed(); Assert.True(new Regex(@"urn:uuid:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}").IsMatch(syndicationFeed.Id)); Assert.AreEqual("Restbucks products and promotions", syndicationFeed.Title.Text); Assert.AreEqual("Product Catalog", syndicationFeed.Authors.First().Name); Assert.AreEqual("Product Catalog", syndicationFeed.Generator); Assert.LessOrEqual(syndicationFeed.LastUpdatedTime.Subtract(now), new TimeSpan(0, 0, 2)); Assert.AreEqual("http://restbucks.com/product-catalog/notifications/?page=2", syndicationFeed.GetViaLink().Uri.AbsoluteUri); Assert.AreEqual("http://restbucks.com/product-catalog/notifications/?page=1", syndicationFeed.GetPrevArchiveLink().Uri.AbsoluteUri); Assert.AreEqual("http://restbucks.com/product-catalog/notifications/recent", syndicationFeed.GetSelfLink().Uri.AbsoluteUri); }
public void ShouldSaveFeedToCurrentDirectory() { InMemoryFileSystem fileSystem = new InMemoryFileSystem(); RecentEventsFeed recentEventsFeed = new RecentEventsFeedBuilder().WithId(2).WithPreviousId(1).WithUris(SampleLinks.Instance).Build(); Assert.AreEqual(0, fileSystem.FileCount(fileSystem.CurrentDirectory)); recentEventsFeed.Save(fileSystem); Assert.AreEqual(1, fileSystem.FileCount(fileSystem.CurrentDirectory)); SyndicationFeed feed = recentEventsFeed.GetSyndicationFeed(); SyndicationFeed rehydratedFeed = SyndicationFeed.Load(fileSystem.CurrentDirectory.GetXmlReader(recentEventsFeed.GetFeedMapping().GetFileName())); Assert.AreEqual(feed.Id, rehydratedFeed.Id); Assert.AreEqual(feed.Items.Count(), rehydratedFeed.Items.Count()); Assert.AreEqual(feed.GetSelfLink().GetAbsoluteUri(), rehydratedFeed.GetSelfLink().GetAbsoluteUri()); Assert.AreEqual(feed.GetViaLink().GetAbsoluteUri(), rehydratedFeed.GetViaLink().GetAbsoluteUri()); Assert.AreEqual(feed.GetPrevArchiveLink().GetAbsoluteUri(), rehydratedFeed.GetPrevArchiveLink().GetAbsoluteUri()); }