public async Task ReturnAll_FinishedContests() { var options = Utils.GetOptions(nameof(ReturnAll_FinishedContests)); var categoryService = new Mock <ICategoryService>().Object; var userService = new Mock <IUserService>().Object; var userStore = new Mock <IUserStore <User> >(); var userManager = new Mock <UserManager <User> >(userStore.Object, null, null, null, null, null, null, null, null).Object; var contextAccessor = new Mock <IHttpContextAccessor>().Object; var userPrincipalFactory = new Mock <IUserClaimsPrincipalFactory <User> >().Object; var signManager = new Mock <SignInManager <User> >(userManager, contextAccessor, userPrincipalFactory, null, null, null, null).Object; using (var arrContext = new PhotoContestContext(options)) { await arrContext.Statuses.AddRangeAsync(Utils.SeedStatuses()); await arrContext.Categories.AddRangeAsync(Utils.SeedCategories()); await arrContext.Photos.AddRangeAsync(Utils.SeedPhotos()); await arrContext.Contests.AddRangeAsync(Utils.SeedContests()); await arrContext.SaveChangesAsync(); } using (var actContext = new PhotoContestContext(options)) { var sut = new ContestService(actContext, contextAccessor, userService, categoryService, userManager, signManager); var result = await sut.GetAllFinishedContestsAsync(); Assert.AreEqual(actContext.Contests .Where(c => c.Status.Name == "Finished") .Count(), result.Count()); Assert.AreEqual(string.Join(",", actContext.Contests.Where(c => c.Status.Name == "Finished")), string.Join(",", result)); } }