public async Task GetAllAsyncShouldWorkCorrectly() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var orderRepo = new EfDeletableEntityRepository <Order>(dbContext); var taskRepo = new EfDeletableEntityRepository <EnginieringTask>(dbContext); var slotRepo = new EfDeletableEntityRepository <InstalationSlot>(dbContext); var moqAddressService = new Mock <IAddressService>(); moqAddressService.Setup(x => x.GetCityIdByAddressIdAsync(It.IsAny <int>())).Returns(Task.FromResult(1)); var service = new TasksService( slotRepo, moqAddressService.Object, taskRepo, orderRepo); var userId = Guid.NewGuid().ToString(); var user2 = Guid.NewGuid().ToString(); var startingTime = DateTime.UtcNow.AddDays(2); var endingTime = startingTime.AddHours(2); await taskRepo.AddAsync(new EnginieringTask { Order = new Order { Status = Status.ForExecution, }, Team = new Team { Employees = new HashSet <ApplicationUser> { new ApplicationUser { Id = userId, }, }, }, InstalationDate = startingTime, }); await taskRepo.AddAsync(new EnginieringTask { Order = new Order { Status = Status.ForExecution, }, Team = new Team { Employees = new HashSet <ApplicationUser> { new ApplicationUser { Id = user2, }, }, }, InstalationDate = startingTime, }); await slotRepo.SaveChangesAsync(); var slots = await service.GetAllAsync <TaskModel>(); Assert.Equal(2, slots.Count()); Assert.Contains(slots, x => x.TeamId == 1); }