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); }
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); } }
public void PushHotNews(IEnumerable <NewsBll> hotNewsCollection) { Parallel.ForEach(hotNewsCollection, async hotNews => { try { await this.hotNewsStorage.AddNews(NewsEntity.FromNewsBll(hotNews)); } catch (StorageException) { } }); }
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); }
public async Task UpdateNews(NewsBll newsBll) { await this.tableStore.UpdateTableEntity(NewsEntity.FromNewsBll(newsBll)); }
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))); }
public async Task AddNews(NewsBll newsBll) { await this.tableStore.AddTableEntity(NewsEntity.FromNewsBll(newsBll)); }