Ejemplo n.º 1
0
        public void TestContainsNews()
        {
            this.mockTableStore.Setup(
                newsStore => newsStore.GetTableEntity <NewsEntity>(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Task.FromResult(NewsEntity.FromNewsBll(DefaultNews)));

            Assert.IsTrue(this.repository.ContainsNews(It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <Guid>()).Result);
        }
Ejemplo n.º 2
0
        public void TestPushNews()
        {
            NewsBll[] hotNews = this.CreateHotNews().ToArray();

            this.hotNewsCreator.PushHotNews(hotNews);

            for (var i = 0; i < 10; ++i)
            {
                Assert.IsTrue(this.hotNewsStorage.ContainsNewsCheckContent(NewsEntity.FromNewsBll(hotNews[i])).Result);
            }
        }
Ejemplo n.º 3
0
 public void PushHotNews(IEnumerable <NewsBll> hotNewsCollection)
 {
     Parallel.ForEach(hotNewsCollection, async hotNews =>
     {
         try
         {
             await this.hotNewsStorage.AddNews(NewsEntity.FromNewsBll(hotNews));
         }
         catch (StorageException)
         {
         }
     });
 }
Ejemplo n.º 4
0
        public void TestFromNewsBll()
        {
            var newsBll = new NewsBll
            {
                Id      = Guid.NewGuid(),
                Date    = DateTime.Parse("2015-05-04"),
                City    = "Malaga",
                Title   = "title",
                Content = "content",
                Author  = "author"
            };

            NewsEntity convertedNews = NewsEntity.FromNewsBll(newsBll);

            Assert.AreEqual("Malaga;2015-05-04", convertedNews.PartitionKey);
            Assert.AreEqual(string.Format("NEWS;{0}", newsBll.Id.ToString()), convertedNews.RowKey);
            Assert.AreEqual(newsBll.Title, convertedNews.Title);
            Assert.AreEqual(newsBll.Content, convertedNews.Content);
            Assert.AreEqual(newsBll.Author, convertedNews.Author);
        }
Ejemplo n.º 5
0
 public async Task UpdateNews(NewsBll newsBll)
 {
     await this.tableStore.UpdateTableEntity(NewsEntity.FromNewsBll(newsBll));
 }
Ejemplo n.º 6
0
 public async Task <bool> ContainsNewsCheckContent(NewsBll newsBll)
 {
     return
         ((await this.tableStore.ListTableEntityByPartitionKey <NewsEntity>(NewsEntity.FromNewsBll(newsBll).PartitionKey))
          .Any(news => string.Equals(newsBll.Title, news.Title) && string.Equals(newsBll.Author, news.Author)));
 }
Ejemplo n.º 7
0
 public async Task AddNews(NewsBll newsBll)
 {
     await this.tableStore.AddTableEntity(NewsEntity.FromNewsBll(newsBll));
 }