Ejemplo n.º 1
0
        public void JMXObjectTest()
        {
            JMXSchemaProviderFactory.RegisterProvider <JMXSchemaProviderMemory>();
            IJMXSchemaProvider sp = JMXSchemaProviderFactory.GetProvider <JMXSchemaProviderMemory>();

            JMXSchemaProviderFactory.SetDefault(sp);
            using (FileLog _logger = new FileLog("ORMSchemaTest", new FileLogSettings()
            {
                DateFolderMask = "yyyy-MM-dd"
            }))
            {
                sp.SaveSchema(creaateTestSchema());

                JMXObject o = new JMXObject("SysCat.SysSchema")
                {
                    ["ID"] = 1
                };
                _logger.Debug(o.ToString());
                string s = o.ToString();
                o.ParseJson(s, null);
                _logger.Debug(o.ToString());
                o = JMXObject.CreateFrom(o.ToString());
                _logger.Debug(o.ToString());
            }
        }
Ejemplo n.º 2
0
 async Task DropDBSchemaTestAsync()
 {
     using (FileLogger _logger = new FileLogger("ORMDBTest", new FileLogSettings()
     {
         DateFolderMask = "yyyy-MM-dd"
     }))
     {
         JMXSchemaProviderDB p = JMXSchemaProviderFactory.GetProvider <JMXSchemaProviderDB>(_cn, _logger);
         await p.ClearCatalogAsync();
     }
 }
Ejemplo n.º 3
0
 async Task SaveSchemaTestAsync()
 {
     using (FileLogger _logger = new FileLogger("ORMDBTest", new FileLogSettings()
     {
         DateFolderMask = "yyyy-MM-dd"
     }))
     {
         JMXSchemaProviderDB p = JMXSchemaProviderFactory.GetProvider <JMXSchemaProviderDB>(_cn, _logger);
         foreach (var s in GetTestSchemas())
         {
             await p.SaveSchemaAsync(s);
         }
     }
 }
Ejemplo n.º 4
0
        public async Task SyncSchemaTestAsync()
        {
            using (FileLogger _logger = new FileLogger("ORMDBTest", new FileLogSettings()
            {
                DateFolderMask = "yyyy-MM-dd"
            }))
            {
                JMXSchemaProviderDB p = JMXSchemaProviderFactory.GetProvider <JMXSchemaProviderDB>(_cn, _logger);
                //foreach( string s in getTestNames())
                //	await p.SyncSchemaAsync(s);
                //await p.SyncSchemaAsync("dbo.SysDataTypesRow");
                await p.SyncSchemaAsync("dbo.Order");

                await p.SyncSchemaAsync("dbo.OrderDetail");
            }
        }
Ejemplo n.º 5
0
 public void Test1()
 {
     using (FileLogger _logger = new FileLogger("ORMDBTest", new FileLogSettings()
     {
         DateFolderMask = "yyyy-MM-dd"
     }))
     {
         JMXSchemaProviderDB p = JMXSchemaProviderFactory.GetProvider <JMXSchemaProviderDB>(_cn, _logger);
         //_logger.Debug("Start speed test for obtain JMXSchemaProviderDB");
         //for (int i = 0; i < 150000; i++)
         //	p.GetSchema("dbo.SysSequence");
         ////	p = JMXSchemaProviderFactory.GetProvider<JMXSchemaProviderDB>(_cn, _logger);
         //_logger.Debug("End speed test for obtain JMXSchemaProviderDB");
         //_logger.Debug(p.GetSchema("dbo.SysSequence"));
     }
 }
Ejemplo n.º 6
0
        async Task ChangeSchemaTestAsync()
        {
            using (FileLogger _logger = new FileLogger("ORMDBTest", new FileLogSettings()
            {
                DateFolderMask = "yyyy-MM-dd"
            }))
            {
                JMXSchemaProviderDB p = JMXSchemaProviderFactory.GetProvider <JMXSchemaProviderDB>(_cn, _logger);
                var schema            = await p.GetSchemaAsync("dbo.SysDataTypesRow");

                //schema.DbObjectName = new JMXObjectName("dbo", "SDTRs");
                schema.Attributes[12].Width = 512;
                await p.SaveSchemaAsync(schema);

                await p.SyncSchemaAsync("dbo.SysDataTypesRow");
            }
        }
Ejemplo n.º 7
0
        public void SerializeTest()
        {
            using (FileLog _logger = new FileLog("ORMSchemaTest", new FileLogSettings()
            {
                DateFolderMask = "yyyy-MM-dd"
            }))
            {
                JMXAttribute a = new JMXAttribute("ID")
                {
                    DataType   = MdbType.@int,
                    IsNullable = false
                };
                string sa = a.ToString();
                //_logger.Debug(sa);
                a = JsonConvert.DeserializeObject <JMXAttribute>(sa);
                //_logger.Debug(a.ToString());
                Assert.AreEqual(sa, a.ToString());
                JMXPrimaryKey pk  = new JMXPrimaryKey("PK_SomeObjects", "SomeAtt", "NextAtt");
                string        spk = pk.ToString();
                //_logger.Debug(spk);
                pk = JsonConvert.DeserializeObject <JMXPrimaryKey>(spk);
                Assert.AreEqual(spk, pk.ToString());
                JMXSchema s = new JMXSchema("SysSchemas")
                {
                    DbObjectName = new JMXObjectName("SysCat", "SysSchemas")
                };
                s.Attributes.Add(a);
                s.PrimaryKey = pk;
                s.Indexes.Add(new JMXIndex("IE1_SysSchemas", "ID"));
                var fk = new JMXForeignKey("FK1")
                {
                    RefObjectName   = "SysCat.SysArea",
                    RefDbObjectName = new JMXObjectName("SysCat", "SysAreas")
                };
                fk.AddKeyMember("AreaID");
                fk.AddRefKeyMember("ID");
                s.ForeignKeys.Add(fk);
                string ss = s.ToString();
                _logger.Debug(ss);
                s = JsonConvert.DeserializeObject <JMXSchema>(ss);
                Assert.AreEqual(ss, s.ToString());
                _logger.Debug("Start speed test fo JMXObject parse from json string");


                JMXSchemaProviderFactory.RegisterProvider <JMXSchemaProviderMemory>();
                JMXSchemaProviderFactory.SetDefault(JMXSchemaProviderFactory.GetProvider <JMXSchemaProviderMemory>());
                JMXSchemaProviderFactory.Default.SaveSchema(creaateTestSchema());
                JMXObject o = new JMXObject("SysCat.SysSchema");
                for (int i = 0; i < 1000; i++)
                {
                    o.ParseJson(ss, null);
                }
                _logger.Debug("Finish speed test");
                _logger.Debug(o.ToString());
                _logger.Debug("Start speed test fo JMXSchema serialize to json string");
                for (int i = 0; i < 1000; i++)
                {
                    ss = JsonConvert.SerializeObject(s);
                }
                _logger.Debug("Finish speed test");
                _logger.Debug("Start speed test fo JMXSchema ToString method to json string");
                for (int i = 0; i < 1000; i++)
                {
                    ss = s.ToString();
                }
                _logger.Debug("Finish speed test");
                _logger.Debug("Start speed test fo JMXSchema parse from json string");
                for (int i = 0; i < 1000; i++)
                {
                    s = JsonConvert.DeserializeObject <JMXSchema>(ss);
                }
                _logger.Debug("Finish speed test");

                //JMXObject o = new JMXObject(JObject.Parse(ss));
                //_logger.Debug((o as JObject).ToString());
                //JsonSerializer serializer = new JsonSerializer();
                //JMXObject o = (JMXObject)serializer.Deserialize(new JTokenReader(JObject.Parse(ss)), typeof(JMXObject));
                //JMXObject o = new JMXObject("Test");
            }
        }