public static OncologiaDbContext Create() { var options = new DbContextOptionsBuilder <OncologiaDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new OncologiaDbContext(options); context.Database.EnsureCreated(); context.Pacientes.AddRange(new[] { new Paciente { PacienteId = 1000, PrimerNombre = "Adam", PrimerApellido = "Cogan" }, new Paciente { PacienteId = 1001, PrimerNombre = "Jason", PrimerApellido = "Taylor" }, new Paciente { PacienteId = 1002, PrimerNombre = "Brendan", PrimerApellido = "Richards" }, }); context.SaveChanges(); return(context); }
public static void InitializeDbForTests(OncologiaDbContext context) { var paciente = new Paciente { PrimerNombre = "Daniel" , PrimerApellido = "Aguilar" , TipoCedula = "CE" , Cedula = "1028999" }; context.Pacientes.Add(paciente); context.SaveChanges(); }
public OncologiaDbContextTests() { // Con Base de Datos real /* * var SetBasePath = Directory.GetCurrentDirectory(); * var baseWeb = SetBasePath.Split("tests")[0] + "src\\WebUI"; * var config = new ConfigurationBuilder() * .SetBasePath(baseWeb) * .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) * .Build(); * * var options = new DbContextOptionsBuilder<OncologiaDbContext>() * .UseSqlServer(config["ConnectionStrings:OncologiaDatabase"]) * .Options; */ // Base de datos en memoria var options = new DbContextOptionsBuilder <OncologiaDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; _sut = new OncologiaDbContext(options); }
public static void Destroy(OncologiaDbContext context) { context.Database.EnsureDeleted(); context.Dispose(); }
public GetPacientesListQueryHandlerTest(QueryTestFixture fixture) { _context = fixture.Context; _mapper = fixture.Mapper; }
public CommandTestBase() { _context = OncologiaContextFactory.Create(); }