示例#1
0
 public B1_TestYourControllerHere_LOB()
 {
     _context        = new VrsContext();
     _controllerLobs = new LobsController(_lobsService);
     _lobsRepository = new LOBsRepository(_context);
     _lobsService    = new LOBsService(_lobsRepository);
 }
示例#2
0
        public EFCore_Context_vs_Controller()
        {
            _context = new VrsContext();

            _controllerLobs = new LobsController(_lobsService);
            _lobsService    = new LOBsService(_lobsRepository);
        }
示例#3
0
        public DashboardService(VrsContext context)
        {
            _context = context;
            _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;

            _dapperRepository = new DapperRespository();
        }
示例#4
0
        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);
            }
        }
示例#5
0
文件: Program.cs 项目: glyder/dev2.0
        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}");
            }
        }
示例#6
0
        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);
        }
示例#7
0
 public UserMaintenanceRepository(VrsContext context)
 {
     _context = context;
 }
示例#8
0
 public UserSessionRepository(VrsContext context)
 {
     _context = context;
 }
示例#9
0
        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);
        }
示例#10
0
 public IndividualsService(VrsContext context)
 {
     _context = context;
     _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }
示例#11
0
 public LOBsRepository(VrsContext context) : base(context)
 {
     _context = context;
     _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }
示例#12
0
 public ProjectsService(VrsContext context)
 {
     _context = context;
     _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }
示例#13
0
 public StoredProceduresController(VrsContext context)
 {
     _context = context;
     _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }
示例#14
0
 public EFCore_Single_vs_First()
 {
     _context = new VrsContext();
 }
示例#15
0
 public UserService(VrsContext context)
 {
     _context = context;
 }
示例#16
0
 public Lookup_InMemory()
 {
     _vrsContext     = new VrsContext();
     _lobsRepository = new LOBsRepository(_vrsContext);
     _lobsService    = new LOBsService(_lobsRepository);
 }
示例#17
0
 public ValuesController(VrsContext context)
 {
     _context = context;
     _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }
示例#18
0
 public EFCore_StoredProcedure_Mapping()
 {
     _context = new VrsContext();
     _dapper  = new DapperRespository();
 }
示例#19
0
 public void InitContext()
 {
     _vrsContext = new VrsContext();
     //VrsDbInitializer.Initialize(_vrsContext, null);
 }
示例#20
0
 public InsuranceTypesRepository(VrsContext context)
     : base(context)
 {
     _context = context;
 }
示例#21
0
 public UserSessionsController(VrsContext context)
 {
     _context = context;
 }
示例#22
0
 public CompaniesRepository(VrsContext context) : base(context)
 {
     _context = context;
 }
示例#23
0
 public EFCoreBaseRepository(VrsContext context)
 {
     _context = context;
 }
示例#24
0
 public SessionService(VrsContext ctx)
 {
     _context = ctx;
 }
示例#25
0
 public EFCore_Async_vs_Sync()
 {
     _context = new VrsContext();
 }
示例#26
0
 public BASEServiceFake()
 {
     _context = GetContextWithData();
     // _context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
 }