Esempio n. 1
0
        public async void BuildDefault()
        {
            Environment.SetEnvironmentVariable("DEVEELDB_ENVIRONMENT", "Production");

            var system = new SystemBuilder()
                         .UseRootPath(Directory.GetCurrentDirectory())
                         .UseSystemServices()
                         .Build();

            Assert.NotNull(system);
            Assert.NotNull(system.Configuration);
            Assert.NotNull(system.Scope);
            Assert.Null(system.ParentContext);
            Assert.Equal("system", system.ContextName);

            var basePath = system.Configuration.RootPath();

            Assert.NotNull(basePath);
            Assert.Equal(Directory.GetCurrentDirectory(), basePath);

            var env = system.Scope.Resolve <ISystemEnvironment>();

            Assert.NotNull(env);
            Assert.Equal("Production", env.EnvironmentName);

            await system.StartAsync();

            Assert.Empty(system.GetDatabases());
        }
Esempio n. 2
0
        public static IDatabase New(IConfiguration config, string dbName, string adminName, string adminPassword)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(dbName))
            {
                throw new ArgumentNullException("dbName");
            }

            config.SetValue("database.name", dbName);

            var builder = new SystemBuilder(config);
            var system  = builder.BuildSystem();

            if (!system.DatabaseExists(dbName))
            {
                return(system.CreateDatabase(config, adminName, adminPassword));
            }
            else
            {
                return(system.OpenDatabase(config));
            }
        }
Esempio n. 3
0
 public void FromDefaultConfig()
 {
     var builder = new SystemBuilder();
     ISystem system = null;
     Assert.DoesNotThrow(() => system = builder.BuildSystem());
     Assert.IsNotNull(system);
     Assert.IsFalse(system.Context.ReadOnly());
     Assert.IsTrue(system.Context.IgnoreIdentifiersCase());
     Assert.AreEqual("APP", system.Context.DefaultSchema());
 }
Esempio n. 4
0
        public void FromDefaultConfig()
        {
            var     builder = new SystemBuilder();
            ISystem system  = null;

            Assert.DoesNotThrow(() => system = builder.BuildSystem());
            Assert.IsNotNull(system);
            Assert.IsFalse(system.Context.ReadOnly());
            Assert.IsTrue(system.Context.IgnoreIdentifiersCase());
            Assert.AreEqual("APP", system.Context.DefaultSchema());
        }
Esempio n. 5
0
        public void TestSetup()
        {
            var systemBuilder = new SystemBuilder();
            systemContext = systemBuilder.BuildSystem();

            var test = TestContext.CurrentContext.Test.Name;

            if (test != "CreateNew" &&
                test != "DatabaseNotExists") {
                var dbConfig = new Configuration.Configuration();
                dbConfig.SetValue("database.name", TestDbName);
                database = systemContext.CreateDatabase(dbConfig, TestAdminUser, TestAdminPass);
            }
        }
Esempio n. 6
0
        public void TestSetup()
        {
            var systemBuilder = new SystemBuilder();

            systemContext = systemBuilder.BuildSystem();

            var test = TestContext.CurrentContext.Test.Name;

            if (test != "CreateNew" &&
                test != "DatabaseNotExists")
            {
                var dbConfig = new Configuration.Configuration();
                dbConfig.SetValue("database.name", TestDbName);
                database = systemContext.CreateDatabase(dbConfig, TestAdminUser, TestAdminPass);
            }
        }
Esempio n. 7
0
        public void ResolveSingleServiceFromRegister()
        {
            var     builder = new SystemBuilder();
            ISystem system  = null;

            Assert.DoesNotThrow(() => system = builder.BuildSystem());
            Assert.IsNotNull(system);

            system.Context.RegisterService <TestService>();

            object serviceObj = null;

            Assert.DoesNotThrow(() => serviceObj = system.Context.ResolveService(typeof(TestService)));
            Assert.IsNotNull(serviceObj);
            Assert.IsInstanceOf <TestService>(serviceObj);

            var service = (TestService)serviceObj;

            Assert.DoesNotThrow(() => service.SayHello());
        }
Esempio n. 8
0
        public void ResolveManyServicesForInterface()
        {
            var builder = new SystemBuilder();
            ISystem system = null;
            Assert.DoesNotThrow(() => system = builder.BuildSystem());
            Assert.IsNotNull(system);

            system.Context.RegisterService<TestService>();
            system.Context.RegisterService<TestService2>();
            system.Context.RegisterService<TestService3>();

            IEnumerable<ITestService> services = null;
            Assert.DoesNotThrow(() => services = system.Context.ResolveAllServices<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]);
        }
Esempio n. 9
0
        public void ResolveInstanceOfServiceByInterface()
        {
            var     builder = new SystemBuilder();
            ISystem system  = null;

            Assert.DoesNotThrow(() => system = builder.BuildSystem());
            Assert.IsNotNull(system);

            system.Context.RegisterInstance(new TestService());
            system.Context.RegisterInstance(new TestService2());
            system.Context.RegisterService <TestService3>();

            IEnumerable <ITestService> services = null;

            Assert.DoesNotThrow(() => services = system.Context.ResolveAllServices <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]);
        }
Esempio n. 10
0
        public void ResolveSingleServiceFromRegister()
        {
            var builder = new SystemBuilder();
            ISystem system = null;
            Assert.DoesNotThrow(() => system = builder.BuildSystem());
            Assert.IsNotNull(system);

            system.Context.RegisterService<TestService>();

            object serviceObj = null;
            Assert.DoesNotThrow(() => serviceObj = system.Context.ResolveService(typeof(TestService)));
            Assert.IsNotNull(serviceObj);
            Assert.IsInstanceOf<TestService>(serviceObj);

            var service = (TestService)serviceObj;
            Assert.DoesNotThrow(() => service.SayHello());
        }