This is the context of a database system, that handles the configurations and services used by all the databases managed within this scope.
Inheritance: Context, ISystemContext
Exemple #1
0
 public void FromDefaultConfig()
 {
     ISystemContext context = null;
     Assert.DoesNotThrow(() => context = new SystemContext(Configuration.Configuration.SystemDefault));
     Assert.IsNotNull(context);
     Assert.IsFalse(context.ReadOnly());
     Assert.IsTrue(context.IgnoreIdentifiersCase());
     Assert.AreEqual("APP", context.DefaultSchema());
 }
Exemple #2
0
        public void ResolveSingleServiceFromRegister()
        {
            ISystemContext context = null;
            Assert.DoesNotThrow(() => context = new SystemContext(Configuration.Configuration.SystemDefault));
            Assert.IsNotNull(context);

            context.ServiceProvider.Register<TestService>();

            object serviceObj = null;
            Assert.DoesNotThrow(() => serviceObj = context.ServiceProvider.Resolve(typeof(TestService)));
            Assert.IsNotNull(serviceObj);
            Assert.IsInstanceOf<TestService>(serviceObj);

            var service = (TestService)serviceObj;
            Assert.DoesNotThrow(() => service.SayHello());
        }
Exemple #3
0
        public void ResolveManyServicesForInterface()
        {
            ISystemContext context = null;
            Assert.DoesNotThrow(() => context = new SystemContext(Configuration.Configuration.SystemDefault));
            Assert.IsNotNull(context);

            context.ServiceProvider.Register<TestService>();
            context.ServiceProvider.Register<TestService2>();
            context.ServiceProvider.Register<TestService3>();

            IEnumerable<ITestService> services = null;
            Assert.DoesNotThrow(() => services = context.ServiceProvider.ResolveAll<ITestService>());
            Assert.IsNotNull(services);

            var serviceList = services.ToList();

            Assert.IsNotEmpty(serviceList);
            Assert.AreEqual(2, serviceList.Count);
            Assert.IsInstanceOf<TestService2>(serviceList[0]);
            Assert.IsInstanceOf<TestService3>(serviceList[1]);
        }
        public void TestSetup()
        {
            testSequenceName = ObjectName.Parse("APP.test_sequence");

            var dbConfig = Configuration.Configuration.Empty;
            dbConfig.SetValue(DatabaseConfigKeys.DatabaseName, "testdb");

            var systemContext = new SystemContext(Configuration.Configuration.SystemDefault);
            var dbContext = new DatabaseContext(systemContext, dbConfig);
            var database = new Database(dbContext);
            database.Create("SA", "12345");
            database.Open();

            transaction = database.CreateTransaction(TransactionIsolation.Serializable);

            if (TestContext.CurrentContext.Test.Name != "CreateNormalSequence") {
                var seqInfo = new SequenceInfo(testSequenceName, new SqlNumber(0), new SqlNumber(1), new SqlNumber(0), new SqlNumber(Int64.MaxValue), 126);
                transaction.CreateSequence(seqInfo);
            }
        }