public void InsertArticle(Article article)
        {
            if (article == null)
                throw (new ArgumentNullException("article"));

            _articleContext.Articles.Add(article);
        }
        public void GetArticles_WhenRepositoryIsNotEmpty_ShouldReturnElementsFromRepository()
        {
            Article art1 = new Article() { Id = 1, Name = "Test_ABS", Price = 13.666 };
            Article art2 = new Article() { Id = 2, Name = "Testing!!!", Price = 6.9 };

            var data = new List<Article>
            {
                art1,
                art2
            }.AsQueryable();

            setMock.As<IQueryable<Article>>().Setup(m => m.Provider).Returns(data.Provider);
            setMock.As<IQueryable<Article>>().Setup(m => m.Expression).Returns(data.Expression);
            setMock.As<IQueryable<Article>>().Setup(m => m.ElementType).Returns(data.ElementType);
            setMock.As<IQueryable<Article>>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var articles = sut.GetArticles();

            Assert.AreEqual(art1, articles.ElementAt(0));
            Assert.AreEqual(art2, articles.ElementAt(1));
        }
 public void UpdateArticle(Article article)
 {
     _articles.First(x => x.Id == article.Id).Name = article.Name;
     _articles.First(x => x.Id == article.Id).Description = article.Description;
     _articles.First(x => x.Id == article.Id).Price = article.Price;
 }
 public void InsertArticle(Article article)
 {
     article.Id = _articles.Select(x => x.Id).Max() + 1;
     _articles.Add(article);
 }
 public void UpdateArticle(Article article)
 {
     _articleContext.Entry(article).State = EntityState.Modified;
 }
示例#6
0
 public void UpdateArticle(Article article)
 {
     _articleRepository.UpdateArticle(article);
 }
示例#7
0
 public void InsertArticle(Article article)
 {
     _articleRepository.InsertArticle(article);
 }
        public void InsertArticle_WhenInputModelIsCorrect_ShouldCallSetAddExactlyOnce()
        {
            Article newArt = new Article() { Id = 1, Name = "Test_ABS", Price = 13.666 };

            sut.InsertArticle(newArt);

            setMock.Verify(m => m.Add(It.IsAny<Article>()), Times.Once());
        }
示例#9
0
 public DbEntityEntry<Article> Entry(Article entity)
 {
     return Entry(entity);
 }