public B1_TestYourControllerHere_LOB() { _context = new VrsContext(); _controllerLobs = new LobsController(_lobsService); _lobsRepository = new LOBsRepository(_context); _lobsService = new LOBsService(_lobsRepository); }
public EFCore_Context_vs_Controller() { _context = new VrsContext(); _controllerLobs = new LobsController(_lobsService); _lobsService = new LOBsService(_lobsRepository); }
public DashboardService(VrsContext context) { _context = context; _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; _dapperRepository = new DapperRespository(); }
public async Task Lobs_DBContext_GetById_2() { using (_vrsContext = GetDBContext("By_Context_Get_2")) { // Arrange string expectedTitle = "Lob2"; int ID = 2; // Act var result = await _vrsContext.tblLOBs.SingleOrDefaultAsync(m => m.LOBID == ID); // Assert Assert.Equal(expectedTitle, result.LOB); } }
public static void RunLobs(VrsContext context) { var lobs = context.tblLOBs.OrderBy(x => x.LOB); foreach (var lob in lobs) { Console.WriteLine($"{lob.LOBID} {lob.LOB}"); } var lobs2 = context.tblLOBs.OrderBy(x => x.LOB); foreach (var lob in lobs2) { Console.WriteLine($"{lob.LOBID} {lob.LOB}"); } }
private static VrsContext GetDBContext(string dbName) { var options = new DbContextOptionsBuilder <VrsContext>() .UseInMemoryDatabase(databaseName: dbName) .Options; var context = new VrsContext(options); var lobs = Enumerable.Range(1, 10) .Select(i => new tblLOBs { LOBID = i, LOB = $"Lob{i}" }); context.tblLOBs.AddRange(lobs); int changed = context.SaveChanges(); return(context); }
public UserMaintenanceRepository(VrsContext context) { _context = context; }
public UserSessionRepository(VrsContext context) { _context = context; }
public VrsContext GetContextWithData() { // http://gunnarpeipman.com/2017/04/aspnet-core-ef-inmemory/ // https://mirkomaggioni.com/2017/07/01/in-memory-db-context-with-ef-core/ // http://fiyazhasan.me/faking-with-in-memory-database-in-asp-net-core-2-0/ // https://garywoodfine.com/entity-framework-core-memory-testing-database/ // https://stormpath.com/blog/tutorial-entity-framework-core-in-memory-database-asp-net-core // http://blog.frankdecaire.com/category/entity-framework/ //var options = new DbContextOptionsBuilder<VrsContext>() // .UseInMemoryDatabase(Guid.NewGuid().ToString()) // .Options; //var context = new VrsContext(options); DbContextOptionsBuilder <VrsContext> builder = new DbContextOptionsBuilder <VrsContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()); var context = new VrsContext(builder.Options); // _repository = new GamesRepository(_context); context.tblLOBs.Add(new tblLOBs { LOBID = 1, LOB = "VIC/ TAS" }); context.tblLOBs.Add(new tblLOBs { LOBID = 2, LOB = "NSW/ ACT" }); context.tblLOBs.Add(new tblLOBs { LOBID = 3, LOB = "QLD/ NT" }); context.tblLOBs.Add(new tblLOBs { LOBID = 4, LOB = "WA" }); context.tblLOBs.Add(new tblLOBs { LOBID = 5, LOB = "SA" }); context.tblLOBs.Add(new tblLOBs { LOBID = 6, LOB = "NATIONAL" }); context.tblLOBs.Add(new tblLOBs { LOBID = 10, LOB = "4 - LOB - NBN" }); context.SaveChanges(); //var beerCategory = new Category { Id = 1, Name = "Beers" }; //var wineCategory = new Category { Id = 2, Name = "Wines" }; //context.Categories.Add(beerCategory); //context.Categories.Add(wineCategory); //context.Products.Add(new Product { Id = 1, Name = "La Trappe Isid'or", Category = beerCategory }); //context.Products.Add(new Product { Id = 2, Name = "St. Bernardus Abt 12", Category = beerCategory }); //context.Products.Add(new Product { Id = 3, Name = "Zundert", Category = beerCategory }); //context.Products.Add(new Product { Id = 4, Name = "La Trappe Blond", Category = beerCategory }); //context.Products.Add(new Product { Id = 5, Name = "La Trappe Bock", Category = beerCategory }); //context.Products.Add(new Product { Id = 6, Name = "St. Bernardus Tripel", Category = beerCategory }); //context.Products.Add(new Product { Id = 7, Name = "Grottenbier Bruin", Category = beerCategory }); //context.Products.Add(new Product { Id = 8, Name = "St. Bernardus Pater 6", Category = beerCategory }); //context.Products.Add(new Product { Id = 9, Name = "La Trappe Quadrupel", Category = beerCategory }); //context.Products.Add(new Product { Id = 10, Name = "Westvleteren 12", Category = beerCategory }); //context.Products.Add(new Product { Id = 11, Name = "Leffe Bruin", Category = beerCategory }); //context.Products.Add(new Product { Id = 12, Name = "Leffe Royale", Category = beerCategory }); //context.SaveChanges(); return(context); }
public IndividualsService(VrsContext context) { _context = context; _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
public LOBsRepository(VrsContext context) : base(context) { _context = context; _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
public ProjectsService(VrsContext context) { _context = context; _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
public StoredProceduresController(VrsContext context) { _context = context; _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
public EFCore_Single_vs_First() { _context = new VrsContext(); }
public UserService(VrsContext context) { _context = context; }
public Lookup_InMemory() { _vrsContext = new VrsContext(); _lobsRepository = new LOBsRepository(_vrsContext); _lobsService = new LOBsService(_lobsRepository); }
public ValuesController(VrsContext context) { _context = context; _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
public EFCore_StoredProcedure_Mapping() { _context = new VrsContext(); _dapper = new DapperRespository(); }
public void InitContext() { _vrsContext = new VrsContext(); //VrsDbInitializer.Initialize(_vrsContext, null); }
public InsuranceTypesRepository(VrsContext context) : base(context) { _context = context; }
public UserSessionsController(VrsContext context) { _context = context; }
public CompaniesRepository(VrsContext context) : base(context) { _context = context; }
public EFCoreBaseRepository(VrsContext context) { _context = context; }
public SessionService(VrsContext ctx) { _context = ctx; }
public EFCore_Async_vs_Sync() { _context = new VrsContext(); }
public BASEServiceFake() { _context = GetContextWithData(); // _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }