示例#1
0
文件: Program.cs 项目: jeswin/AgileFx
        static void Main(string[] args)
        {
            var provider = DbEntityProvider.From(@"c:\data\Northwind.mdf", "Test.NorthwindWithAttributes");

            //var provider = DbEntityProvider.From(@"c:\data\Northwind.accdb", "Test.NorthwindWithAttributes");
            //var provider = DbEntityProvider.From(@"c:\data\Northwind.mdb", "Test.NorthwindWithAttributes");
            //var provider = DbEntityProvider.From(@"c:\data\Northwind.sdf", "Test.NorthwindWithAttributes");
            //var provider = DbEntityProvider.From("IQToolkit.Data.MySqlClient", "Northwind", "Test.MySqlNorthwind");
            //var provider = DbEntityProvider.From("IQToolkit.Data.SQLite", @"c:\data\Northwind.db3", "Test.NorthwindWithAttributes");

            //provider.Log = Console.Out;
            provider.Connection.Open();
            //provider.Cache = new QueryCache(5);

            try
            {
                var db = new Northwind(provider);

                //NorthwindTranslationTests.Run(db, true);
                NorthwindExecutionTests.Run(db);
                //NorthwindCUDTests.Run(db);
                //MultiTableTests.Run(new MultiTableContext(provider.New(new AttributeMapping(typeof(MultiTableContext)))));
                //NorthwindPerfTests.Run(db, "TestStandardQuery");
            }
            finally
            {
                provider.Connection.Close();
            }
        }
示例#2
0
        private static bool RunTest(string selection)
        {
            if (selection.Equals("q", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            if (selection.Equals("s", StringComparison.OrdinalIgnoreCase))
            {
                if (adoProviderName == "IQToolkit.Data.OracleClient")
                {
                    adoProviderName = "IQToolkit.Data.ODP";
                }
                else
                {
                    adoProviderName = "IQToolkit.Data.OracleClient";
                }
                return(true);
            }

            string connectionStringName = "Oracle";
            string providerName         = ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName;
            string connectionString     = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;

            var provider = DbEntityProvider.From(adoProviderName, connectionString, "Test.NorthwindWithAttributes");


            if (selection.StartsWith("log", StringComparison.OrdinalIgnoreCase))
            {
                if (selection.Equals("log on", StringComparison.OrdinalIgnoreCase))
                {
                    logEnabled = true;
                }
                else if (selection.Equals("log off", StringComparison.OrdinalIgnoreCase))
                {
                    logEnabled = false;
                }

                Console.WriteLine(String.Format("Log is {0}.", logEnabled ? "On" : "Off"));
                return(true);
            }

            if (logEnabled)
            {
                provider.Log = Console.Out;
            }
            else
            {
                provider.Log = null;
            }

            provider.Connection.Open();
            //provider.Cache = new QueryCache(5);
            try
            {
                var db = new Northwind(provider);

                if (selection.Contains("0") || selection.Contains("1"))
                {
                    NorthwindTranslationTests.Run(db, true);
                }
                if (selection.Contains("0") || selection.Contains("2"))
                {
                    NorthwindExecutionTests.Run(db);
                }
                if (selection.Contains("0") || selection.Contains("3"))
                {
                    NorthwindCUDTests.Run(db);
                }
                if (selection.Contains("0") || selection.Contains("4"))
                {
                    MultiTableTests.Run(new MultiTableContext(provider.New(new AttributeMapping(typeof(MultiTableContext)))));
                }
                if (selection.Contains("0") || selection.Contains("5"))
                {
                    NorthwindPerfTests.Run(db, "TestStandardQuery");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                provider.Connection.Close();
            }

            return(true);
        }