public async Task RemoveAsync(News news) { if (news == (News)null) throw new ArgumentNullException("news"); this._newsRepository.Remove(news); await this._newsRepository.UnitOfWork.CommitAsync(); }
public async Task UpdateAsync(News news) { if (news == (News)null) throw new ArgumentNullException("news"); this._newsRepository.SetModified (news); await this._newsRepository.UnitOfWork.CommitAsync(); }
public void NewsRepository_AddTest_InValidNews() { INewsRepository newsRepository = IoCFactory.Instance.CurrentContainer.Resolve<INewsRepository>(); News news = new News() { Title = null, Summary = "", //Image = "test Image" }; newsRepository.Add(news); newsRepository.UnitOfWork.CommitAndRefreshChanges(); }
public void NewsRepository_AddTest_ValidNews() { INewsRepository newsRepository = IoCFactory.Instance.CurrentContainer.Resolve<INewsRepository>(); newsRepository.UnitOfWork.RollbackChanges(); News news1 = new News() { Id = new Guid("1cd1ae08-8e48-c902-0147-08d1ca79fb6a"), Title = "test title", Summary = "test Texte" }; //news1.Image = "test Image"; newsRepository.Add(news1); newsRepository.UnitOfWork.Commit(); News byId = newsRepository.GetElementById(news1.Id); Assert.IsNotNull((object)byId); Assert.IsTrue(byId.Id == news1.Id); }