Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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();
        }