예제 #1
0
        private async Task EnqueueMedia(Queue <Media> medias)
        {
            Logger.Trace($"Adding medias to explore queue");
            var stopTags = ConfigurationManager.BotSettings.StopTags;

            ExploreResponseMessage exploreReponse;

            try
            {
                exploreReponse = await FeedManager.Explore();
            }
            catch (Exception ex)
            {
                Logger.Critical($"Critical error on adding medias to explore queue", ex);
                return;
            }
            foreach (var media in exploreReponse.Medias.Where(
                         x =>
                         x.LikeCount >= ConfigurationManager.BotSettings.MinLikeToLike &&
                         x.LikeCount < ConfigurationManager.BotSettings.MaxLikeToLike && !x.HasLiked &&
                         (x.Caption == null || !x.Caption.Text.ToUpper().ContainsAny(stopTags))))
            {
                medias.Enqueue(media);
            }
        }
예제 #2
0
        public void ParseFeedEmptyImageParsesCorrectly()
        {
            var doc   = XDocument.Parse("<xml><item><title>title</title><pubDate>pub</pubDate></item></xml>");
            var items = FeedManager.ParseFeed(doc);

            Assert.That(items.Single(i => i.Title == "title" && i.PubDate == "pub" && string.IsNullOrEmpty(i.Image)) != null);
        }
예제 #3
0
        public static void RunProductFeedVariantIssueCheck()
        {
            var feedManager = new FeedManager("7ad2d0bb-6c44-4a93-a146-6c8ed845860b", "TEST", 0);
            var prod        = new Product("59095",
                                          "Bear June Medium",
                                          "<p>.</p>",
                                          "souvenirs/novelties/bear-june-medium",
                                          "siteUrl/filedepository/productimages/Souvenirs/novelties/bear-june-medium-1.jpg",
                                          new List <string> {
                "Novelties > Souvenirs"
            });

            var variant = new Product("5909565",
                                      "Bear June Medium",
                                      "<p>.</p>",
                                      "souvenirs/novelties/bear-june-medium",
                                      "siteUrl/filedepository/productimages/Souvenirs/novelties/bear-june-medium-1.jpg",
                                      new List <string> {
                "Novelties > Souvenirs"
            });

            variant.Attributes.Add("Personalisable", new List <string> {
                "false"
            });
            variant.ParentId = "59095";


            var res1          = feedManager.AddProduct(variant);
            var res2          = feedManager.AddProduct(prod);
            var valid         = feedManager.Validate();
            var publishResult = feedManager.PublishAsync().Result;

            Console.WriteLine($"Published: {publishResult.Success.ToString()}. Error: {publishResult.PublishProductFeedResult.Error}");
        }
예제 #4
0
        public static void RunParallelAddProductFeed()
        {
            var feedManager = new FeedManager("7ad2d0bb-6c44-4a93-a146-6c8ed845860b", "TEST", 0);

            System.Threading.Tasks.Parallel.ForEach(_products, (prod) =>
            {
                feedManager.AddProduct(prod);
            });

            System.Threading.Tasks.Parallel.ForEach(_accountPrices, (accountPrice) =>
            {
                feedManager.AddAccountPrice(accountPrice);
            });

            var valid = feedManager.Validate();

            if (valid.Success)
            {
                var publishResult = feedManager.PublishAsync().Result;
                Console.WriteLine($"Published: {publishResult.Success.ToString()}. Error: {publishResult.PublishProductFeedResult.Error}");
            }
            else
            {
                Console.WriteLine("Invalid feed");
            }
        }
예제 #5
0
 private void InicializarObjetoFeedManager()
 {
     p_objFeedManager = new FeedManager();
     //eventos - delegates
     p_objFeedManager.AoLerFeedPodcast += new FeedManager.AoLerFeedPodcastHandler(AoLerFeedPodcast);
     p_objFeedManager.AoGerarErro      += new FeedManager.AoGerarErroHandler(AoGerarErroFeed);
 }
예제 #6
0
        private async void btnEditPodcast_Click(object sender, EventArgs e)
        {
            if (Validator.IsListViewItemSelected(lvPodcasts))
            {
                if (Validator.IsAlla(txtURL.Text))
                {
                    Feed feedToChange = (Feed)lvPodcasts.SelectedItems[0].Tag;
                    _FeedGroup.Remove(feedToChange);

                    Category selectedCategory = (Category)cmbCat.SelectedItem;
                    var      time             = int.Parse(cmbFreq.SelectedItem.ToString());

                    Feed newFeed = null;

                    Task  taskA = Task.Run(() => newFeed = FeedManager.CreateFeed(txtURL.Text, selectedCategory, new UpdateFrequency(time)));
                    await taskA;

                    _FeedGroup.Add(newFeed);

                    ClearEpisodes();
                    UpdateFeedListView();
                }
                else
                {
                    MessageBox.Show("Fyll i alla fälten korrekt");
                }
            }
            else
            {
                MessageBox.Show("Markera först en feed i listan för att ändra den");
            }
        }
예제 #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.create_post_activity);

            FindViewById(Resource.Id.postButton).Click += async delegate {
                var name    = (FindViewById(Resource.Id.nameEditText) as EditText).Text;
                var message = (FindViewById(Resource.Id.messageEditText) as EditText).Text;

                var post = new Post()
                {
                    Author = new User()
                    {
                        Name = name
                    },
                    Text = message
                };

                ProgressDialog mDialog = new ProgressDialog(this);
                mDialog.SetMessage("Please wait...");
                mDialog.SetCancelable(false);
                mDialog.Show();

                await FeedManager.Post(post);

                mDialog.Hide();

                SetResult(Result.Ok);
                Finish();
            };
        }
예제 #8
0
        /// <inheritdoc />
        protected override AppEntry GetAppEntry(IIntegrationManager integrationManager, ref FeedUri interfaceUri)
        {
            #region Sanity checks
            if (integrationManager == null)
            {
                throw new ArgumentNullException(nameof(integrationManager));
            }
            if (interfaceUri == null)
            {
                throw new ArgumentNullException(nameof(interfaceUri));
            }
            #endregion

            var appEntry = base.GetAppEntry(integrationManager, ref interfaceUri);
            var feed     = FeedManager.GetFresh(interfaceUri);

            // Detect feed changes that may make an AppEntry update necessary
            if (!appEntry.CapabilityLists.UnsequencedEquals(feed.CapabilityLists))
            {
                string changedMessage = string.Format(Resources.CapabilitiesChanged, appEntry.Name);
                if (Handler.Ask(
                        changedMessage + " " + Resources.AskUpdateCapabilities,
                        defaultAnswer: false, alternateMessage: changedMessage))
                {
                    integrationManager.UpdateApp(appEntry, feed);
                }
            }

            return(appEntry);
        }
예제 #9
0
        private void TrimItemsListWithMaxItemsLimitTest(bool useSerializer)
        {
            var feed = new Feed(new Uri("http://www.test.com/rss/feed"));

            feed = !useSerializer ? feed : SerializerHelper.Clone(feed);

            var feedManager = new FeedManager();

            feedManager.Feeds.Add(feed);

            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2", "name1" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.MaxItemsLimit = 2;
            Assert.IsTrue(new[] { "name3", "name2" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.MaxItemsLimit = 3;
            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2", "name1" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.MaxItemsLimit = 1;
            Assert.IsTrue(new[] { "name3" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.MaxItemsLimit = 0;
            Assert.IsTrue(new string[0].SequenceEqual(feed.Items.Select(x => x.Name)));
        }
예제 #10
0
        private void TrimItemsListWithItemLifetimeTest(bool useSerializer)
        {
            var feed = new Feed(new Uri("http://www.test.com/rss/feed"));

            feed = !useSerializer ? feed : SerializerHelper.Clone(feed);

            var feedManager = new FeedManager();

            feedManager.Feeds.Add(feed);

            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2", "name1" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.ItemLifetime = TimeSpan.FromDays(6);
            Assert.IsTrue(new[] { "name3", "name2" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.ItemLifetime = TimeSpan.FromDays(11);
            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2", "name1" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.ItemLifetime = TimeSpan.FromDays(2);
            Assert.IsTrue(new[] { "name3" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.ItemLifetime = TimeSpan.FromDays(0.5);
            Assert.IsTrue(new string[0].SequenceEqual(feed.Items.Select(x => x.Name)));
        }
예제 #11
0
        public void SetDataManager()
        {
            var feedManagerA = new FeedManager();

            Assert.AreSame(feedManagerA, feedManagerA.Feeds.Single().DataManager);

            var feedA1 = new Feed(new Uri("http://www.test.com/rss/feed"));

            Assert.IsNull(feedA1.DataManager);

            feedManagerA.Feeds.Add(feedA1);
            Assert.AreSame(feedManagerA, feedA1.DataManager);

            feedManagerA.Feeds.Remove(feedA1);
            Assert.IsNull(feedA1.DataManager);

            // Now use the serialzer with one Feed added

            feedManagerA.Feeds.Add(feedA1);
            var feedManagerB = SerializerHelper.Clone(feedManagerA);

            Assert.AreSame(feedManagerB, feedManagerB.Feeds.First().DataManager);

            var feedB1 = feedManagerB.Feeds.Last();

            Assert.AreSame(feedManagerB, feedB1.DataManager);

            feedManagerB.Feeds.Remove(feedB1);
            Assert.IsNull(feedB1.DataManager);

            feedManagerB.Feeds.Add(feedB1);
            Assert.AreSame(feedManagerB, feedB1.DataManager);
        }
예제 #12
0
 static void Main(string[] args)
 {
     try
     {
         Validation.ValidateArguments(args);
         Console.WriteLine("Beginning feed processing with the following: ");
         Console.WriteLine($"User file path: { args[0] }");
         Console.WriteLine($"Tweet file path: { args[0] }");
         Console.Write("Are you OK with this? Y/N: ");
         if (Console.ReadLine().ToUpper() == "Y")
         {
             FeedManager manager = new FeedManager();
             Console.WriteLine(manager.ProcessFiles(args[0], args[1]));
         }
     }
     catch (Exception exception)
     {
         Console.Write("Error processing feed:");
         Console.WriteLine(exception.Message);
     }
     finally
     {
         Console.Write("Press any key to exit");
         Console.ReadLine();
     }
 }
예제 #13
0
        private static void IsLoadingCoreTest(bool useSerializer)
        {
            var feed1 = new Feed(new Uri("http://www.test.com/rss/feed"));
            var feed2 = new Feed(new Uri("http://www.test.com/rss/feed"));

            feed1 = !useSerializer ? feed1 : SerializerHelper.Clone(feed1);
            feed2 = !useSerializer ? feed2 : SerializerHelper.Clone(feed2);

            var feedManager = new FeedManager();

            feedManager.Feeds.Add(feed1);
            feedManager.Feeds.Add(feed2);

            Assert.IsFalse(feed1.IsLoading);
            feed1.StartLoading();
            Assert.IsTrue(feed1.IsLoading);
            feed1.SetLoadError(new InvalidOperationException("test"), "display test");
            Assert.IsFalse(feed1.IsLoading);
            Assert.AreEqual("test", feed1.LoadError !.Message);
            Assert.AreEqual("display test", feed1.LoadErrorMessage);
            feed1.StartLoading();
            Assert.IsNull(feed1.LoadError);
            Assert.IsNull(feed1.LoadErrorMessage);

            Assert.IsFalse(feed2.IsLoading);
            feed2.StartLoading();
            Assert.IsTrue(feed2.IsLoading);
            feed2.UpdateItems(new FeedItem[0]);
            Assert.IsFalse(feed2.IsLoading);
        }
예제 #14
0
        public void ParseFeedItemParsesCorrectly()
        {
            var doc   = XDocument.Parse("<xml><item><title>title</title><pubDate>pub</pubDate><enclosure url=\"image\"></enclosure></item></xml>");
            var items = FeedManager.ParseFeed(doc);

            Assert.That(items.Single(i => i.Title == "title" && i.PubDate == "pub" && i.Image == "image") != null);
        }
예제 #15
0
        private async void UpdateQuestionsView(bool forceQuery)
        {
            StatusBlock.Visibility = Visibility.Collapsed;

            await QuestionsManager.LoadAsync();

            IList <BindableQuestion> list = null;

            if (!forceQuery)
            {
                list = QuestionsManager.GetSortedQuestions();
            }

            if (list == null || list.Count == 0)
            {
                // Deleting sites or tags cleans the questions collection. Query again.
                LoadingBar.ShowPaused = false;
                await FeedManager.QueryWebsitesAsync();

                LoadingBar.ShowPaused = true;

                list = QuestionsManager.GetSortedQuestions();

                if (list.Count == 0)
                {
                    StatusBlock.Visibility = Visibility.Visible;
                }
            }

            QuestionsManager.DisplayQuestions(QuestionsView, list);
        }
예제 #16
0
 private void CatalogSearch(string?name, VersionRange?versionRange)
 {
     foreach (var feed in GetCatalogResults(name))
     {
         if (AllVersions)
         {
             foreach (var implementation in FeedManager.GetFresh(feed.Uri).Implementations)
             {
                 var requirements = new Requirements(feed.Uri)
                 {
                     ExtraRestrictions = { { feed.Uri, implementation.Version } }
                 };
                 Yield(requirements, feed, implementation);
             }
         }
         else
         {
             var requirements = new Requirements(feed.Uri);
             if (versionRange != null)
             {
                 requirements.ExtraRestrictions[requirements.InterfaceUri] = versionRange;
             }
             Yield(requirements, feed);
         }
     }
 }
예제 #17
0
    /// <inheritdoc/>
    public override ExitCode Execute()
    {
        FeedUri feedUri;
        ICollection <FeedUri> interfaces;
        Stability             suggestedStabilityPolicy;

        if (AdditionalArgs.Count == 2)
        { // Main interface for feed specified explicitly
            interfaces = new[] { GetCanonicalUri(AdditionalArgs[0]) };
            feedUri    = GetCanonicalUri(AdditionalArgs[1]);
            suggestedStabilityPolicy = Stability.Unset;
        }
        else
        { // Determine interfaces from feed content (<feed-for> tags)
            feedUri = GetCanonicalUri(AdditionalArgs[0]);

            var feed = FeedManager.GetFresh(feedUri);
            interfaces = feed.FeedFor.Select(reference => reference.Target).WhereNotNull().ToList();
            if (interfaces.Count == 0)
            {
                throw new OptionException(string.Format(Resources.MissingFeedFor, feedUri), null);
            }

            suggestedStabilityPolicy = feed.Implementations.Select(x => x.Stability).DefaultIfEmpty().Max();
        }

        return(ExecuteHelper(interfaces, new FeedReference {
            Source = feedUri
        }, suggestedStabilityPolicy));
    }
예제 #18
0
        public void SetDataManager()
        {
            var feedManagerA = new FeedManager();
            Assert.AreSame(feedManagerA, feedManagerA.Feeds.Single().DataManager);

            var feedA1 = new Feed(new Uri("http://www.test.com/rss/feed"));
            Assert.IsNull(feedA1.DataManager);

            feedManagerA.Feeds.Add(feedA1);
            Assert.AreSame(feedManagerA, feedA1.DataManager);

            feedManagerA.Feeds.Remove(feedA1);
            Assert.IsNull(feedA1.DataManager);

            // Now use the serialzer with one Feed added

            feedManagerA.Feeds.Add(feedA1);
            var feedManagerB = SerializerHelper.Clone(feedManagerA);
            Assert.AreSame(feedManagerB, feedManagerB.Feeds.First().DataManager);

            var feedB1 = feedManagerB.Feeds.Last();
            Assert.AreSame(feedManagerB, feedB1.DataManager);

            feedManagerB.Feeds.Remove(feedB1);
            Assert.IsNull(feedB1.DataManager);

            feedManagerB.Feeds.Add(feedB1);
            Assert.AreSame(feedManagerB, feedB1.DataManager);
        }
        internal void Init()
        {
            try
            {
                // Get Rss from API
                var feedManager = new FeedManager();
                var rss         = feedManager.GetRss();

                // Prepare collection
                var itemCollection = new ObservableCollection <Item>();
                foreach (var item in rss.channel.Items)
                {
                    // Parse Html content using custom render for each platform
                    if (MainPageImpl != null)
                    {
                        item.Description = MainPageImpl.FromHtml(item.Description);
                    }

                    // Format date
                    item.Date = item.GetFormattedDate();

                    // Add item to collection
                    itemCollection.Add(item);
                }

                // Attach collection to view
                View.Render(itemCollection);
            }
            catch (RestResponseErrorException e)
            {
                // handle the possible rest exceptions
                DisplayError(e);
            }
        }
예제 #20
0
        private void Yield([NotNull] Requirements requirements, [CanBeNull] Feed feed = null, [CanBeNull] ImplementationBase implementation = null)
        {
            if (implementation == null)
            {
                var selections = Solver.TrySolve(requirements);
                if (selections != null)
                {
                    implementation = selections.Implementations[0];
                }
            }
            if (feed == null)
            {
                feed = FeedManager.GetFeed(requirements.InterfaceUri);
            }

            var sourceUri = feed.CatalogUri ?? feed.Uri;

            _request.YieldSoftwareIdentity(
                fastPath: requirements.ToJsonString(),
                name: feed.Name,
                version: (implementation == null || implementation.Version == null) ? null : implementation.Version.ToString(),
                versionScheme: null,
                summary: feed.Summaries.GetBestLanguage(CultureInfo.CurrentUICulture),
                source: (sourceUri == null) ? null : sourceUri.ToStringRfc(),
                searchKey: feed.Name,
                fullPath: null,
                packageFileName: feed.Name);
        }
예제 #21
0
 private void CatalogSearch([NotNull] string name, [CanBeNull] VersionRange versionRange)
 {
     foreach (var feed in GetCatalogResults(name))
     {
         if (AllVersions)
         {
             foreach (var implementation in FeedManager.GetFeedFresh(feed.Uri).Elements.OfType <Implementation>())
             {
                 var requirements = new Requirements(feed.Uri)
                 {
                     ExtraRestrictions = { { feed.Uri, new VersionRange(implementation.Version) } }
                 };
                 Yield(requirements, feed, implementation);
             }
         }
         else
         {
             var requirements = new Requirements(feed.Uri);
             if (versionRange != null)
             {
                 requirements.ExtraRestrictions[requirements.InterfaceUri] = versionRange;
             }
             Yield(requirements, feed);
         }
     }
 }
예제 #22
0
 public FeedVideoIncrementalSource(IFeedGroup feedGroup, HohoemaApp hohoemaApp, PageManager pageManager)
     : base(hohoemaApp, "Feed:" + feedGroup.Label)
 {
     _FeedGroup            = feedGroup;
     _FavFeedManager       = hohoemaApp.FeedManager;
     _NiconicoMediaManager = hohoemaApp.MediaManager;
     _PageManager          = pageManager;
 }
예제 #23
0
파일: Program.cs 프로젝트: GorkyR/Fidd
        static void Main(string[] args)
        {
            var feed_manager = new FeedManager("Feeds");

            try { feed_manager.AddFeedAsync("tonsky.me").Wait(); } catch (Exception e) {; }
            try { feed_manager.AddFeedAsync("devonzuegel.com").Wait(); } catch (Exception e) {; }
            try { feed_manager.AddFeedAsync("slatestarcodex.com").Wait(); } catch (Exception e) {; }
        }
예제 #24
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(145, 50);

            var feedManager = new FeedManager(FileReadUsersProcess.Instance, FileReadTweetsProcess.Instance, ConstructSocialFeedProcess.Instance);

            feedManager.BuildSocialFeed();
        }
예제 #25
0
        public async Task <IActionResult> DeletePost(Guid guid)
        {
            await _postDal.DeletePost(guid);

            await FeedManager.GenerateRSS();

            return(this.Ok());
        }
예제 #26
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (interfaceUri == null)
            {
                throw new ArgumentNullException("interfaceUri");
            }
            if (integrationManager == null)
            {
                throw new ArgumentNullException("integrationManager");
            }
            #endregion

            if (RemoveOnly())
            {
                RemoveOnly(integrationManager, interfaceUri);
                return(ExitCode.OK);
            }

            var appEntry = GetAppEntry(integrationManager, ref interfaceUri);
            var feed     = FeedManager.GetFeed(interfaceUri);

            if (NoSpecifiedIntegrations())
            {
                var state = new IntegrationState(integrationManager, appEntry, feed);
Retry:
                Handler.ShowIntegrateApp(state);
                try
                {
                    state.ApplyChanges();
                }
                #region Error handling
                catch (ConflictException ex)
                {
                    if (Handler.Ask(
                            Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                            defaultAnswer: false, alternateMessage: ex.Message))
                    {
                        goto Retry;
                    }
                }
                catch (InvalidDataException ex)
                {
                    if (Handler.Ask(
                            Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                            defaultAnswer: false, alternateMessage: ex.Message))
                    {
                        goto Retry;
                    }
                }
                #endregion

                return(ExitCode.OK);
            }

            RemoveAndAdd(integrationManager, feed, appEntry);
            return(ExitCode.OK);
        }
예제 #27
0
        /// <inheritdoc/>
        public override ExitCode Execute()
        {
            foreach (var file in ArgumentUtils.GetFiles(AdditionalArgs, "*.xml"))
            {
                FeedManager.ImportFeed(file.FullName);
            }

            return(ExitCode.OK);
        }
예제 #28
0
    /// <inheritdoc/>
    public override ExitCode Execute()
    {
        foreach (var file in Paths.ResolveFiles(AdditionalArgs, "*.xml"))
        {
            FeedManager.ImportFeed(file.FullName);
        }

        return(ExitCode.OK);
    }
예제 #29
0
        public async void UpdateTable()
        {
            RefreshControl.BeginRefreshing();
            feed = await FeedManager.Get();

            feed.Sort((p1, p2) => p2.Created.CompareTo(p1.Created));
            TableView.ReloadData();
            RefreshControl.EndRefreshing();
        }
예제 #30
0
        public void Feeder_ContainsMethodTest()
        {
            var feeder   = new FeedManager();
            var provider = new ProviderMock(new Uri("http://feeds.feedburner.com/TEDTalks_video"), new FillerMock(null));

            feeder.Register(provider);
            bool isContains = feeder.Contains(provider);

            Assert.IsTrue(isContains);
        }
예제 #31
0
        public static void RunUserFeed()
        {
            var feedManager = new FeedManager("7ad2d0bb-6c44-4a93-a146-6c8ed845860b", "TEST", 0);

            feedManager.AddUsers(_users);
            var valid         = feedManager.Validate();
            var publishResult = feedManager.PublishAsync().Result;

            Console.WriteLine($"Published: {publishResult.Success.ToString()}. Error: {publishResult.PublishUserFeedResult.Error}");
        }
예제 #32
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            feedManager = new FeedManager();
            selectionService = Container.GetExport<SelectionService>();

            controller = Container.GetExport<NewsFeedsController>();
            controller.FeedManager = feedManager;

            // Wait for Run to udate the first Feed
            controller.Run();
            Context.WaitFor(() => feedManager.Feeds.Single().Items.Count == 3, TimeSpan.FromSeconds(1));
        }
예제 #33
0
        public void MergeTest()
        {
            var feedManagerA = new FeedManager();
            feedManagerA.Feeds.Remove(feedManagerA.Feeds.Single());
            var feedA1 = new Feed(new Uri("http://www.test.com/rss/feedA1"));
            var feedA2 = new Feed(new Uri("http://www.test.com/rss/feedA2"));
            feedManagerA.Feeds.Add(feedA1);
            feedManagerA.Feeds.Add(feedA2);
            var item = new FeedItem(new Uri("http://www.test.com/rss/feed"), new DateTimeOffset(2020, 5, 5, 12, 0, 0, new TimeSpan(1, 0, 0)), "name", "desc", "author");
            feedA2.UpdateItems(new[] { item });
            Assert.IsFalse(feedManagerA.Feeds.Last().Items.Single().MarkAsRead);

            var feedManagerB = new FeedManager()
            {
                ItemLifetime = TimeSpan.FromDays(42),
                MaxItemsLimit = 43
            };
            feedManagerB.Feeds.Remove(feedManagerB.Feeds.Single());
            var feedB1 = new Feed(new Uri("http://www.test.com/rss/feedB1"));
            var feedB2 = new Feed(new Uri("http://www.test.com/rss/feedA2"));
            feedManagerB.Feeds.Add(feedB1);
            feedManagerB.Feeds.Add(feedB2);
            feedB2.UpdateItems(new[] { item }, cloneItemsBeforeInsert: true);
            feedB2.Items.Single().MarkAsRead = true;

            feedManagerA.Merge(feedManagerB);

            Assert.AreEqual(42, feedManagerA.ItemLifetime.Value.Days);
            Assert.AreEqual(43u, feedManagerA.MaxItemsLimit.Value);
            Assert.IsTrue(new[] { "http://www.test.com/rss/feedB1", "http://www.test.com/rss/feedA2" }.SequenceEqual(feedManagerA.Feeds.Select(x => x.Uri.ToString())));
            Assert.IsTrue(feedManagerA.Feeds.Last().Items.Single().MarkAsRead);


            // Just remove one element => this way the Merge does not create new instances
            var feedManagerC = new FeedManager();
            feedManagerC.Feeds.Remove(feedManagerC.Feeds.Single());
            var feedC2 = new Feed(new Uri("http://www.test.com/rss/feedA2"));
            feedManagerC.Feeds.Add(feedC2);
            feedC2.UpdateItems(new[] { item }, cloneItemsBeforeInsert: true);
            feedC2.Items.Single().MarkAsRead = false;
            var itemA = feedManagerA.Feeds.Last().Items.Single();

            feedManagerA.Merge(feedManagerC);

            Assert.IsTrue(new[] { "http://www.test.com/rss/feedA2" }.SequenceEqual(feedManagerA.Feeds.Select(x => x.Uri.ToString())));
            Assert.AreSame(itemA, feedManagerA.Feeds.Last().Items.Single());
            Assert.IsFalse(itemA.MarkAsRead);
        }
예제 #34
0
 public async Task<FeedManager> LoadAsync()
 {
     // NOTE: Load must be called just once! See feedManagerCompletion
     FeedManager feedManager;
     try
     {
         feedManager = await appDataService.LoadCompressedFileAsync<FeedManager>(dataFileName) ?? new FeedManager();
     }
     catch (Exception ex)
     {
         // Better to forget the settings (data loss) as to never start the app again
         Debug.Assert(false, "LoadAsync", ex.ToString());
         feedManager = new FeedManager();
     }
     feedManagerCompletion.SetResult(feedManager);
     return feedManager;
 }
예제 #35
0
파일: FeedTest.cs 프로젝트: jbe2277/waf
        private void IsLoadingCoreTest(bool useSerializer)
        {
            var feed1 = new Feed(new Uri("http://www.test.com/rss/feed"));
            var feed2 = new Feed(new Uri("http://www.test.com/rss/feed"));
            feed1 = !useSerializer ? feed1 : SerializerHelper.Clone(feed1);
            feed2 = !useSerializer ? feed2 : SerializerHelper.Clone(feed2);

            var feedManager = new FeedManager();
            feedManager.Feeds.Add(feed1);
            feedManager.Feeds.Add(feed2);

            Assert.IsTrue(feed1.IsLoading);
            feed1.LoadError = new InvalidOperationException("test");
            Assert.IsFalse(feed1.IsLoading);

            Assert.IsTrue(feed2.IsLoading);
            feed2.UpdateItems(new FeedItem[0]);
            Assert.IsFalse(feed2.IsLoading);
        }
예제 #36
0
파일: FeedTest.cs 프로젝트: jbe2277/waf
        private void TrimItemsListWithMaxItemsLimitTest(bool useSerializer)
        {
            var feed = new Feed(new Uri("http://www.test.com/rss/feed"));
            feed = !useSerializer ? feed : SerializerHelper.Clone(feed);

            var feedManager = new FeedManager();
            feedManager.Feeds.Add(feed);

            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2", "name1" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.MaxItemsLimit = 2;
            Assert.IsTrue(new[] { "name3", "name2" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.MaxItemsLimit = 3;
            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2", "name1" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.MaxItemsLimit = 1;
            Assert.IsTrue(new[] { "name3" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.MaxItemsLimit = 0;
            Assert.IsTrue(new string[0].SequenceEqual(feed.Items.Select(x => x.Name)));
        }
예제 #37
0
파일: FeedTest.cs 프로젝트: jbe2277/waf
        private void UnreadItemsCountCoreTest(bool useSerializer)
        {
            var feed = new Feed(new Uri("http://www.test.com/rss/feed"));
            var feedManager = new FeedManager();
            feedManager.Feeds.Add(feed);
            feed.UpdateItems(new[] {
                new FeedItem(new Uri("http://www.test.com/rss/feed/1"), new DateTimeOffset(2020, 5, 5, 12, 0, 0, new TimeSpan(1, 0, 0)), "name1", "desc", "author"),
                new FeedItem(new Uri("http://www.test.com/rss/feed/2"), new DateTimeOffset(2020, 5, 5, 12, 0, 0, new TimeSpan(1, 0, 0)), "name2", "desc", "author"),
            });
            feed = !useSerializer ? feed : SerializerHelper.Clone(feed);
            
            Assert.AreEqual(2, feed.UnreadItemsCount);

            feed.Items[0].MarkAsRead = true;

            Assert.AreEqual(1, feed.UnreadItemsCount);
        }
예제 #38
0
파일: FeedTest.cs 프로젝트: jbe2277/waf
        private void TrimItemsListWithItemLifetimeTest(bool useSerializer)
        {
            var feed = new Feed(new Uri("http://www.test.com/rss/feed"));
            feed = !useSerializer ? feed : SerializerHelper.Clone(feed);

            var feedManager = new FeedManager();
            feedManager.Feeds.Add(feed);

            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2", "name1" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.ItemLifetime = TimeSpan.FromDays(6);
            Assert.IsTrue(new[] { "name3", "name2" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.ItemLifetime = TimeSpan.FromDays(11);
            UpdateFeedItems(feed);
            Assert.IsTrue(new[] { "name3", "name2", "name1" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.ItemLifetime = TimeSpan.FromDays(2);
            Assert.IsTrue(new[] { "name3" }.SequenceEqual(feed.Items.Select(x => x.Name)));

            feedManager.ItemLifetime = TimeSpan.FromDays(0.5);
            Assert.IsTrue(new string[0].SequenceEqual(feed.Items.Select(x => x.Name)));
        }
예제 #39
0
        public async void Run()
        {
            Navigate();
            shellViewModel.Value.Show();

            feedManager = await dataController.Value.LoadAsync();

            selectionService.FeedManager = feedManager;
            newsFeedsController.Value.FeedManager = feedManager;
            newsFeedsController.Value.Run();
            lastUpdate = DateTime.Now;
            settingsController.Value.FeedManager = feedManager;
            if (feedListViewModel.IsValueCreated) { feedListViewModel.Value.FeedManager = feedManager; }
        }