Exemplo n.º 1
0
        public void DocDB_MYSQL_XML()
        {
            WizardManager target = new WizardManager(); // TODO: Initialize to an appropriate value

            target.myDoc              = new DocDbObject();
            target.myDoc.CurExportor  = new XmlExportor();
            target.myDoc.TargetFile   = "C:\\testOutputDBFile_FromMySql.xml";
            target.myDoc.SourceDbType = CoreEA.CoreE.UsedDatabaseType.MySql;
            target.myDoc.LoginInfo    = new LoginInfo_MySql()
            {
                Server   = "localhost",
                Username = "******",
                Pwd      = "noway",
                Database = "test",
            };

            CoreEA.ICoreEAHander srcHandle = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.MySql).X_Handler;
            srcHandle.Open(target.myDoc.LoginInfo);
            string usedTable = string.Empty;

            if (srcHandle.IsOpened)
            {
                usedTable = srcHandle.GetTableListInDatabase()[0];
            }
            BaseTableSchema schema = srcHandle.GetTableSchemaInfoObject(usedTable);

            List <DBObject> testData = new List <DBObject>();

            testData.Add(new DBObject()
            {
                TableName        = schema.TableName,
                ColumnName       = schema.Columns[0].ColumnName,
                Category         = "Tets1",
                Description      = "Test1",
                DbType           = schema.Columns[0].ColumnType,
                Length           = schema.Columns[0].CharacterMaxLength,
                OrdinaryPosition = schema.Columns[0].OrdinalPosition,
            });

            testData.Add(new DBObject()
            {
                TableName        = schema.TableName,
                ColumnName       = schema.Columns[1].ColumnName,
                Category         = "Tets2",
                DbType           = schema.Columns[1].ColumnType,
                Length           = schema.Columns[1].CharacterMaxLength,
                OrdinaryPosition = schema.Columns[1].OrdinalPosition,
            });

            target.myDoc.DbObjectList = testData;

            bool result = target.Export();

            Assert.IsTrue(result);
        }
Exemplo n.º 2
0
        public void DocDB_SqlServer_XML()
        {
            WizardManager target = new WizardManager(); // TODO: Initialize to an appropriate value

            target.myDoc              = new DocDbObject();
            target.myDoc.CurExportor  = new XmlExportor();
            target.myDoc.TargetFile   = "C:\\testOutputDBFile_FromSqlServer.xml";
            target.myDoc.SourceDbType = CoreEA.CoreE.UsedDatabaseType.SqlServer;

            List <string> tableList = new List <string>();

            CoreEA.ICoreEAHander srcHandle = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlServer).X_Handler;
            srcHandle.Open(new CoreEA.LoginInfo.LoginInfo_SqlServer()
            {
                X_Server              = "",
                X_UserName            = "",
                X_Pwd                 = "",
                X_Database            = "",
                IsTrustedConn         = false,
                X_CurDbConnectionMode = CoreEA.Args.CurDbServerConnMode.SqlServer2000
            });
            if (srcHandle.IsOpened)
            {
                tableList = srcHandle.GetTableListInDatabase();
            }

            tableList = tableList.Take(4).ToList();
            string usedTable = tableList[0];

            BaseTableSchema schema = srcHandle.GetTableSchemaInfoObject(usedTable);

            List <DBObject> testData = new List <DBObject>();

            testData.Add(new DBObject()
            {
                TableName        = schema.TableName,
                ColumnName       = schema.Columns[0].ColumnName,
                Category         = "Tets1",
                DbType           = schema.Columns[0].ColumnType,
                Length           = schema.Columns[0].CharacterMaxLength,
                OrdinaryPosition = schema.Columns[0].OrdinalPosition,
            });

            target.myDoc.DbObjectList = testData;

            bool result = target.Export();

            Assert.IsTrue(result);
        }
Exemplo n.º 3
0
        public void DocDB_SSCE_XML()
        {
            WizardManager target = new WizardManager(); // TODO: Initialize to an appropriate value

            target.myDoc              = new DocDbObject();
            target.myDoc.CurExportor  = new XmlExportor();
            target.myDoc.TargetFile   = "C:\\testOutputDBFile_FromSqlce.xml";
            target.myDoc.SourceDbType = CoreEA.CoreE.UsedDatabaseType.SqlCE35;
            target.myDoc.LoginInfo    = new LoginInfo_SSCE()
            {
                DbName = GlobalInfo.SqlCE_TestFile,
            };
            CoreEA.ICoreEAHander srcHandle = new CoreEA.CoreE(CoreEA.CoreE.UsedDatabaseType.SqlCE35).X_Handler;
            srcHandle.Open(target.myDoc.LoginInfo);
            string usedTable = string.Empty;

            if (srcHandle.IsOpened)
            {
                usedTable = srcHandle.GetTableListInDatabase()[0];
            }
            //here we just test the first table
            BaseTableSchema schema = srcHandle.GetTableSchemaInfoObject(usedTable);

            List <DBObject> testData = new List <DBObject>();

            foreach (var item in schema.Columns)
            {
                testData.Add(new DBObject()
                {
                    TableName        = schema.TableName,
                    ColumnName       = item.ColumnName,
                    Category         = "Column",
                    Description      = "",
                    DbType           = item.ColumnType,
                    Length           = item.CharacterMaxLength,
                    OrdinaryPosition = item.OrdinalPosition,
                });
            }


            target.myDoc.DbObjectList = testData;

            bool result = target.Export();

            Assert.AreEqual(true, result);
        }