public async Task CreateAsyncShouldWorkCorrectly() { 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 orderId = Guid.NewGuid().ToString(); var slotId = 1; var orderId2 = Guid.NewGuid().ToString(); var slotId2 = 2; await slotRepo.AddAsync(new InstalationSlot { StartingTime = DateTime.UtcNow, }); await slotRepo.AddAsync(new InstalationSlot { StartingTime = DateTime.UtcNow, }); await slotRepo.SaveChangesAsync(); await orderRepo.AddAsync(new Order { Id = orderId, }); await orderRepo.AddAsync(new Order { Id = orderId2, }); await orderRepo.SaveChangesAsync(); await service.CreateAsync(orderId, slotId); await service.CreateAsync(orderId2, slotId2); var tasks = await taskRepo.All().ToListAsync(); Assert.Equal(2, tasks.Count()); Assert.Contains(tasks, x => x.OrderId == orderId); Assert.Contains(tasks, x => x.OrderId == orderId2); }