コード例 #1
0
ファイル: NewsApiEvent.cs プロジェクト: ryo0ka/planetnews
 public NewsApiEvent(int id, NewsApiArticle article, string country, string language)
 {
     _id       = id;
     _article  = article;
     _country  = country;
     _language = language;
 }
コード例 #2
0
        public NewsApiEvent MakeEvent(NewsApiArticle article, string country)
        {
            var sourceId = article.Source.Id;

            _sources.TryGetValue(sourceId ?? "", out var source);
            var language = source?.Language;

            return(new NewsApiEvent(_nextId++, article, country, language));
        }
コード例 #3
0
        public void AttachNullSource()
        {
            var factory = new NewsApiEventFactory(new[]
            {
                new NewsApiSource("source A", "", "", "", "", "lang A", ""),
            });

            var article1 = new NewsApiArticle(new NewsApiSourceShort("source B", ""), "", "", "", "", "", null);
            var event1   = factory.MakeEvent(article1, "");

            Assert.AreEqual(null, event1.Language);
        }
コード例 #4
0
        public void AttachId()
        {
            var factory = new NewsApiEventFactory(new[]
            {
                new NewsApiSource("", "source A", "", "", "", "", ""),
            });

            var article1 = new NewsApiArticle(new NewsApiSourceShort("", "source A"), "", "", "", "", "", null);
            var article2 = new NewsApiArticle(new NewsApiSourceShort("", "source A"), "", "", "", "", "", null);
            var event1   = factory.MakeEvent(article1, "");
            var event2   = factory.MakeEvent(article2, "");

            Assert.AreEqual(0, event1.Id);
            Assert.AreEqual(1, event2.Id);
        }