public void Setup() { /*var optionsSqlServer = new DbContextOptionsBuilder<BancoContext>() * .UseSqlServer("Server=.\\;Database=Banco;Trusted_Connection=True;MultipleActiveResultSets=true") * .Options;*/ var optionsInMemory = new DbContextOptionsBuilder <LibranzasContext>().UseInMemoryDatabase("Libranzas").Options; _context = new LibranzasContext(optionsInMemory); }
static void Main(string[] args) { /*var optionsSqlServer = new DbContextOptionsBuilder<BancoContext>() * .UseSqlServer("Server=.\\;Database=Banco;Trusted_Connection=True;MultipleActiveResultSets=true") * .Options;*/ var optionsInMemory = new DbContextOptionsBuilder <LibranzasContext>() .UseInMemoryDatabase("Banco") .Options; LibranzasContext context = new LibranzasContext(optionsInMemory); }
public void SetUp() { /*var optionsSqlServer = new DbContextOptionsBuilder<BancoContext>() * .UseSqlServer("Server=.\\;Database=Banco;Trusted_Connection=True;MultipleActiveResultSets=true") * .Options;*/ var optionsInMemory = new DbContextOptionsBuilder <LibranzasContext>().UseInMemoryDatabase("Libranzas").Options; _context = new LibranzasContext(optionsInMemory); unitOfWork = new UnitOfWork(_context); crearEmpleadoService = new EmpleadoService(unitOfWork); var request = new CrearEmpleadoRequest { Cedula = "1065840833", Nombre = "Duvan", Salario = 1200000 }; crearEmpleadoService.CrearEmpleado(request); crearCreditoService = new CreditoService(unitOfWork); }
public void ConsultarEmpledoConCreditosEfTest() { var optionsSqlServer = new DbContextOptionsBuilder <LibranzasContext>() .UseSqlServer(@"Server=LAPTOP-GEQ2K9D2\MSSQLSERVER01;Database=Libranzas;Trusted_Connection=True;MultipleActiveResultSets=true") .Options; List <Empleado> empleados = null; _context = new LibranzasContext(optionsSqlServer); try { empleados = _context.Empleados.Include(i => i.Creditos).Where(t => t.Cedula == "1065840833").ToList(); //empleados = _context.Empleado.Include(i => i.Creditos).Where(t => t.Cedula == "1065840833").ToList(); } catch (System.Exception) { throw; } Assert.IsNotNull(empleados); }
public CreditoController(LibranzasContext context, IUnitOfWork unitOfWork) { _unitOfWork = unitOfWork; _context = context; CreditoService = new CreditoService(_unitOfWork); }
//Se Recomienda solo dejar la Unidad de Trabajo public EmpleadoController(LibranzasContext context, IUnitOfWork unitOfWork) { _unitOfWork = unitOfWork; _context = context; empleadoService = new EmpleadoService(_unitOfWork); }