public async void GetTest() { var options = new DbContextOptionsBuilder <MCContext>() .UseInMemoryDatabase("MC") .Options; // Insert seed data into the database using one instance of the context await using (var context = new MCContext(options)) { await context.Person.AddRangeAsync(new List <Person> { new Person { Id = 1, FirstName = "Unit Test 1" }, new Person { Id = 2, FirstName = "Unit Test 2" }, new Person { Id = 3, FirstName = "Unit Test 3" } }).ConfigureAwait(false); _ = await context.SaveChangesAsync().ConfigureAwait(false); } // Use a clean instance of the context to run the test await using (var context = new MCContext(options)) { var sut = new PersonRepository(context); var result = await sut.GetPersons("", "ID", true).ConfigureAwait(false); Assert.Equal(3, result.Count); } }
public async Task SaveChangesAsync() { try { await _context.SaveChangesAsync(); await _mcContext.SaveChangesAsync(); await _maestrosContext.SaveChangesAsync(); await _mooreveContext.SaveChangesAsync(); await _sapContext.SaveChangesAsync(); await _clientesContext.SaveChangesAsync(); await _facturacionContext.SaveChangesAsync(); } catch (System.Exception e) { var msg = e.InnerException.Message; } }
public async Task SaveChangesAsync() { await _context.SaveChangesAsync(); }
public async Task <int> CompleteAsync() { return(await _context.SaveChangesAsync().ConfigureAwait(false)); }
public async Task InsertTeam(Team team) { _context.Teams.Add(team); await _context.SaveChangesAsync(); }