示例#1
0
        public XunitKnstArchSql()
        {
            var services = new ServiceCollection();

            services.AddKnstArchitectureSql();
            services.AddTransient <IDbConnection>(sp => DbConnectionMoq.GetMemorySqlite());

            var serviceProvider = services.BuildServiceProvider();

            ServiceScope    = serviceProvider.CreateScope();
            ServiceProvider = ServiceScope.ServiceProvider;
        }
示例#2
0
        public XunitKnstArchEF()
        {
            var services = new ServiceCollection();

            services.TryAddKnstArchitecture();
            services.AddTransient <ITestEFDbSession, TestEFDbSession>();
            services.AddTransient <IEFCoreDbSession>(sp => sp.GetRequiredService <ITestEFDbSession>());
            services.AddScoped <ITestEFUnitOfWork, TestEFUnitOfWork>();
            services.AddScoped <IEFCoreUnitOfWork>(sp => sp.GetRequiredService <ITestEFUnitOfWork>());
            services.TryAddKnstDbContexts();
            services.AddTransient <IDbConnection>(sp => DbConnectionMoq.GetMemorySqlite());

            var serviceProvider = services.BuildServiceProvider();

            ServiceScope    = serviceProvider.CreateScope();
            ServiceProvider = ServiceScope.ServiceProvider;
        }