Ejemplo n.º 1
0
        public FactoryDbContextTest()
        {
            Assembly asm = Assembly.GetExecutingAssembly();

            FactoryDbContext.ClearRegisteredItems();
            FactoryDbContext.RegisterDbContext(asm, "MockedDbContext", "Its.Onix.Core.Databases.MockedDbContext");
            FactoryDbContext.SetLoggerFactory(null);

            var items = new Dictionary <string, PluginEntry>();

            items.Add("MockedDbContext_1", new PluginEntry(asm, "MockedDbContext_1", "Its.Onix.Core.Databases.MockedDbContext"));

            FactoryDbContext.RegisterDbContexts(items);
        }
Ejemplo n.º 2
0
        public void UnknownDbContextNameTest(string ctxName, string host, int port, string db, string uname, string pw, string provider)
        {
            try
            {
                DbCredential credential = null;
                if (string.IsNullOrEmpty(provider))
                {
                    credential = new DbCredential(host, port, db, uname, pw);
                }
                else
                {
                    credential = new DbCredential(host, port, db, uname, pw, provider);
                }

                BaseDbContext opt = FactoryDbContext.CreateDbContextObject(ctxName, credential);
                Assert.True(false, "Exception shoud be throw for unknow application name!!!");
            }
            catch (Exception e)
            {
                Assert.True(true, e.Message);
            }
        }
Ejemplo n.º 3
0
        public void knownDbContextNameTest(string ctxName, string host, int port, string db, string uname, string pw, string provider)
        {
            try
            {
                DbCredential credential = null;
                if (string.IsNullOrEmpty(provider))
                {
                    credential = new DbCredential(host, port, db, uname, pw);
                }
                else
                {
                    credential = new DbCredential(host, port, db, uname, pw, provider);
                }

                BaseDbContext opt = FactoryDbContext.CreateDbContextObject(ctxName, credential);

                Assert.IsNotNull(opt, "Object created from factory must be null!!!");
            }
            catch (Exception e)
            {
                Assert.True(false, e.Message);
            }
        }