Esempio n. 1
0
        public void ExerciseEngine()
        {
            string file = @"C:\test.sdf";

            if (System.IO.File.Exists(file))
            {
                System.IO.File.Delete(file);
            }
            SqlCeEngineHelper testEngine = new SqlCeEngineHelper(string.Format("Data Source={0};", file));

            testEngine.Execute(SqlCeEngineHelper.EngineAction.Create);
            Assert.IsTrue(System.IO.File.Exists(file), "Create OK");

            testEngine.Execute(SqlCeEngineHelper.EngineAction.Shrink);

            testEngine.Execute(SqlCeEngineHelper.EngineAction.Compact);

            testEngine.Execute(SqlCeEngineHelper.EngineAction.SetOption, "Data Source=;Password=123!!");

            //Use new password
            testEngine = new SqlCeEngineHelper(string.Format("Data Source={0};Password=123!!", file));

            testEngine.Execute(SqlCeEngineHelper.EngineAction.Shrink);

            //testEngine = new SqlCeEngineHelper("data source=C:\\Northwind.sdf");
            //testEngine.Execute(SqlCeEngineHelper.EngineAction.Upgrade);
        }
Esempio n. 2
0
        public void CodePlex13272()
        {
            string file = @"C:\tmp\test.sdf";

            if (System.IO.File.Exists(file))
            {
                System.IO.File.Delete(file);
            }
            SqlCeEngineHelper testEngine = new SqlCeEngineHelper(string.Format("Data Source={0};", file));

            testEngine.Execute(SqlCeEngineHelper.EngineAction.Create);
            Assert.IsTrue(System.IO.File.Exists(file), "Create OK");

            SqlCeCommandHelper cmdHelper = new SqlCeCommandHelper(string.Format("Data Source={0};", file));

            Program.Options options = new Program.Options();
            options.QueryFile = @"C:\tmp\CodePlex\sqlcecmd\Test\goscript.sql";

            cmdHelper.RunCommands(options);

            SqlCeCommand cmd = new SqlCeCommand("SELECT COUNT(*) FROM [example]", new SqlCeConnection(string.Format("Data Source={0};", file)));

            cmd.Connection.Open();
            int count = (int)cmd.ExecuteScalar();

            Assert.AreEqual(count, 1);
        }
Esempio n. 3
0
        public void ExerciseFileInput()
        {
            string file = @"C:\data\test.sdf";

            if (System.IO.File.Exists(file))
            {
                System.IO.File.Delete(file);
            }
            SqlCeEngineHelper testEngine = new SqlCeEngineHelper(string.Format("Data Source={0};", file));

            testEngine.Execute(SqlCeEngineHelper.EngineAction.Create);
            Assert.IsTrue(System.IO.File.Exists(file), "Create OK");

            SqlCeCommandHelper cmdHelper = new SqlCeCommandHelper(string.Format("Data Source={0};", file));

            Program.Options options = new Program.Options();
            options.QueryFile = @"C:\Data\SQLCE\Test\ExportSqlCETest\northwind.sql";

            cmdHelper.RunCommands(options);

            SqlCeCommand cmd = new SqlCeCommand("SELECT COUNT(*) FROM [Order Details]", new SqlCeConnection(string.Format("Data Source={0};", file)));

            cmd.Connection.Open();
            int count = (int)cmd.ExecuteScalar();

            Assert.AreEqual(count, 2820);
        }
Esempio n. 4
0
        public void ExerciseParser()
        {
            string file = @"C:\test.sdf";

            if (System.IO.File.Exists(file))
            {
                System.IO.File.Delete(file);
            }
            SqlCeEngineHelper testEngine = new SqlCeEngineHelper(string.Format("Data Source={0};", file));

            testEngine.Execute(SqlCeEngineHelper.EngineAction.Create);
            Assert.IsTrue(System.IO.File.Exists(file), "Create OK");

            SqlCeCommandHelper cmdHelper = new SqlCeCommandHelper(string.Format("Data Source={0};", file));

            Program.Options options = new Program.Options();

            options.QueryFile = @"C:\Data\SQLCE\SqlCeCmdTest\northwind.sql";
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            cmdHelper.RunCommands(options);
            System.Diagnostics.Debug.Write("Time to run: " + sw.ElapsedMilliseconds.ToString());
            sw.Stop();
            cmdHelper.Dispose();

            //if (System.IO.File.Exists(file))
            //{
            //    System.IO.File.Delete(file);
            //}
            //SqlCeEngineHelper testEngine2 = new SqlCeEngineHelper(string.Format("Data Source={0};", file));
            //testEngine.Execute(SqlCeEngineHelper.EngineAction.Create);
            //Assert.IsTrue(System.IO.File.Exists(file), "Create OK");

            //SqlCeCommandHelper cmdHelper2 = new SqlCeCommandHelper(string.Format("Data Source={0};", file));
            //Program.Options options2 = new Program.Options();

            //options.UseBatch = false;
            //options.QueryFile = @"C:\Data\SQLCE\SqlCeCmdTest\nworders.sql";
            //sw.Start();
            //cmdHelper2.RunCommands(options, true);
            //System.Diagnostics.Debug.Write("QA: " + sw.ElapsedMilliseconds.ToString());
            //sw.Stop();
            //cmdHelper2.Dispose();
        }