Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static void InitializeDbForTests(OncologiaDbContext context)
        {
            var paciente = new Paciente {
                PrimerNombre     = "Daniel"
                , PrimerApellido = "Aguilar"
                , TipoCedula     = "CE"
                , Cedula         = "1028999"
            };

            context.Pacientes.Add(paciente);

            context.SaveChanges();
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public static void Destroy(OncologiaDbContext context)
        {
            context.Database.EnsureDeleted();

            context.Dispose();
        }
 public GetPacientesListQueryHandlerTest(QueryTestFixture fixture)
 {
     _context = fixture.Context;
     _mapper  = fixture.Mapper;
 }
Ejemplo n.º 6
0
 public CommandTestBase()
 {
     _context = OncologiaContextFactory.Create();
 }