public HomeController(RoleManager <IdentityRole> roleManager, UserManager <ApplicationUser> userManager, IArticles allArticles, IArticlesCategory allCategories, IArticlesAccess allArticlesAccess) { _allArticles = allArticles; _allCategories = allCategories; _allArticlesAccess = allArticlesAccess; _roleManager = roleManager; _userManager = userManager; }
private void PrepareMocks(List <Article> data) { var mockArticlesSet = new Mock <DbSet <Article> >(); mockArticlesSet.As <IQueryable <Article> >().Setup(m => m.Provider).Returns(data.AsQueryable().Provider); mockArticlesSet.As <IQueryable <Article> >().Setup(m => m.Expression).Returns(data.AsQueryable().Expression); mockArticlesSet.As <IQueryable <Article> >().Setup(m => m.ElementType).Returns(data.AsQueryable().ElementType); mockArticlesSet.As <IQueryable <Article> >().Setup(m => m.GetEnumerator()).Returns(data.AsQueryable().GetEnumerator()); articleContextMock.Setup(c => c.Articles).Returns(mockArticlesSet.Object); articleContextMock.Setup(x => x.Articles.Add(It.IsAny <Article>())).Callback((Article x) => articleToBeAdded = x); articleContextMock.Setup(x => x.SaveChangesAsync(It.IsAny <CancellationToken>())).ReturnsAsync(1); articleContextFactoryMock.Setup(x => x.CreateArticleContext()).Returns(articleContextMock.Object); articlesAccess = new ArticlesAccess(articleContextFactoryMock.Object); }
public ArticlesProvider(IArticlesAccess articlesAccess, IErrorListProvider errorListProvider) { this.articlesAccess = articlesAccess; this.errorListProvider = errorListProvider; }