コード例 #1
0
 public void IdentityReseedDuringRefresh_TableWithNoRows2()
 {
     InitializeTheDatabase();
     SqlDataFresh dataFresh = new SqlDataFresh(connectionString);
     dataFresh.RemoveDataFreshFromDatabase();
     dataFresh.PrepareDatabaseforDataFresh(true);
     ExecuteNonQuery("insert into movie2 (movieid, title) values (1, 'mike brockey takes over the world');");
     dataFresh.RefreshTheDatabase();
 }
コード例 #2
0
 public void IdentityReseedWorksWithTablesThatUseReservedWords()
 {
     InitializeTheDatabase();
     SqlDataFresh dataFresh = new SqlDataFresh(connectionString);
     dataFresh.RemoveDataFreshFromDatabase();
     dataFresh.PrepareDatabaseforDataFresh(true);
     ExecuteNonQuery("insert into [check] (title) values ('mike brockey takes over the world');");
     dataFresh.RefreshTheDatabase();
 }
コード例 #3
0
ファイル: DbRecreator.cs プロジェクト: bwrobel/Experts
        public static void PrepareDataFresh()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["dataConnection"].ConnectionString;

            CheckDbConnection(connectionString);

            var dataFresh = new SqlDataFresh(connectionString);
            dataFresh.SnapshotPath = new DirectoryInfo(@"C:\experts_snapshots\");
            dataFresh.PrepareDatabaseforDataFresh(true);
        }
コード例 #4
0
 public void IdentityReseedDuringRefresh()
 {
     InitializeTheDatabase();
     SqlDataFresh dataFresh = new SqlDataFresh(connectionString);
     dataFresh.PrepareDatabaseforDataFresh(true);
     int id = Convert.ToInt32(ExecuteScalar("insert into author (lastname, firstname) values ('brockey', 'mike'); select @@identity;"));
     Assert.AreEqual(6, id);
     dataFresh.RefreshTheDatabase();
     int id2 = Convert.ToInt32(ExecuteScalar("insert into author (lastname, firstname) values ('brockey', 'mike'); select @@identity;"));
     Assert.AreEqual(6, id2);
 }
コード例 #5
0
 public void IdentityReseedDuringRefresh_TableWithNoRows()
 {
     InitializeTheDatabase();
     SqlDataFresh dataFresh = new SqlDataFresh(connectionString);
     dataFresh.PrepareDatabaseforDataFresh(true);
     int id = Convert.ToInt32(ExecuteScalar("insert into movie (title) values ('mike brockey takes over the world'); select @@identity;"));
     Assert.AreEqual(1, id);
     dataFresh.RefreshTheDatabase();
     int id2 = Convert.ToInt32(ExecuteScalar("insert into movie (title) values ('mike brockey takes over the world'); select @@identity;"));
     Assert.AreEqual(1, id2);
     int id3 = Convert.ToInt32(ExecuteScalar("insert into movie (title) values ('mike brockey takes over the world 2'); select @@identity;"));
     Assert.AreEqual(2, id3);
 }
コード例 #6
0
        public void Start(string[] args)
        {
            ConsoleWrite("DataFresh provided by Entropy Zero Consulting");

            if (args == null || args.Length < 2)
            {
                WriteUsage();
                return;
            }

            for (int i = 0; i < args.Length; i = i + 2)
            {
                this.arguments.Add(args[i].Replace("-", ""), args[i + 1]);
                //ConsoleWrite(args[i] + ": " +args[i+1]);
            }

            if (!CheckForRequiredArguments(this.arguments))
            {
                return;
            }

            connectionString = string.Format(@"user id={0};password={1};Initial Catalog={2};Data Source={3};",
                                             this.arguments["u"],
                                             this.arguments["p"],
                                             this.arguments["d"],
                                             this.arguments["s"]);

            SqlDataFresh dataFresh = new SqlDataFresh(connectionString, true);

            string snapshotPath = this.arguments["sp"];

            if (snapshotPath != null)
            {
                snapshotPath = snapshotPath.Replace("\"", "");
                if (!snapshotPath.EndsWith(@"\"))
                {
                    snapshotPath += @"\";
                }

                ConsoleWrite("snapshotPath = {0}", snapshotPath);
                string fullPath = Path.GetFullPath(snapshotPath);
                ConsoleWrite("fullPath = {0}", fullPath);
                dataFresh.SnapshotPath = new DirectoryInfo(snapshotPath);
            }

            string command = this.arguments["c"].ToUpper();

            switch (command)
            {
            case "PREPARE":
                bool   ignoreSnapshot         = false;
                string ignoreSnapshotArgument = arguments["ignoresnapshot"];
                if (ignoreSnapshotArgument != null)
                {
                    if (ignoreSnapshotArgument == "1")
                    {
                        ignoreSnapshot = true;
                    }
                }
                dataFresh.PrepareDatabaseforDataFresh(!ignoreSnapshot);
                break;

            case "REFRESH":
                dataFresh.RefreshTheDatabase();
                break;

            case "FORCEREFRESH":
                dataFresh.RefreshTheEntireDatabase();
                break;

            case "REMOVE":
                dataFresh.RemoveDataFreshFromDatabase();
                break;

            case "SNAPSHOT":
                dataFresh.CreateSnapshot();
                break;

            case "FOO":
                //no nothing
                break;

            default:
                ConsoleWrite("Command '{0}' was not recognized", command);
                break;
            }
        }
コード例 #7
0
        public void PrepDatabaseforDataFresh()
        {
            SqlDataFresh dataFresh = new SqlDataFresh(connectionString);

            dataFresh.RemoveDataFreshFromDatabase();
            Assert.IsFalse(dataFresh.TableExists(dataFresh.ChangeTrackingTableName));
            Assert.IsFalse(dataFresh.ProcedureExists(dataFresh.ExtractProcedureName));
            Assert.IsFalse(dataFresh.ProcedureExists(dataFresh.ImportProcedureName));
            Assert.IsFalse(dataFresh.ProcedureExists(dataFresh.PrepareProcedureName));
            Assert.IsFalse(dataFresh.ProcedureExists(dataFresh.RefreshProcedureName));

            dataFresh.PrepareDatabaseforDataFresh();
            Assert.IsTrue(dataFresh.TableExists(dataFresh.ChangeTrackingTableName));
            Assert.IsTrue(dataFresh.ProcedureExists(dataFresh.ExtractProcedureName));
            Assert.IsTrue(dataFresh.ProcedureExists(dataFresh.ImportProcedureName));
            Assert.IsTrue(dataFresh.ProcedureExists(dataFresh.PrepareProcedureName));
            Assert.IsTrue(dataFresh.ProcedureExists(dataFresh.RefreshProcedureName));
        }
コード例 #8
0
 public void SnapshopPath_ManualOverrideTrailingBackslash()
 {
     SqlDataFresh dataFresh = new SqlDataFresh(connectionString);
     string tempPath = @"c:\temp\folder";
     dataFresh.SnapshotPath = new DirectoryInfo(tempPath);
     Assert.AreEqual(@"c:\temp\folder\", dataFresh.SnapshotPath.FullName);
 }
コード例 #9
0
 public void SnapshopPath_Resetting()
 {
     SqlDataFresh dataFresh = new SqlDataFresh(connectionString);
     dataFresh.SnapshotPath = null;
     Assert.IsTrue(dataFresh.SnapshotPath.FullName.IndexOf("Snapshot_DataFreshSample") > -1);
 }
コード例 #10
0
 public void SnapshopPath_ManualOverride()
 {
     SqlDataFresh dataFresh = new SqlDataFresh(connectionString);
     DirectoryInfo tempPath = new DirectoryInfo(Path.GetTempPath());
     dataFresh.SnapshotPath = tempPath;
     Console.Out.WriteLine("dataFresh.SnapshotPath.FullName = {0}", dataFresh.SnapshotPath.FullName);
     Assert.AreEqual(tempPath.FullName, dataFresh.SnapshotPath.FullName);
 }
コード例 #11
0
 public void ShouldNotRefreshDeltaRunnerTable()
 {
     InitializeTheDatabase();
     SqlDataFresh dataFresh = new SqlDataFresh(connectionString);
     dataFresh.RemoveDataFreshFromDatabase();
     dataFresh.PrepareDatabaseforDataFresh(true);
     ExecuteNonQuery("insert into [dr_deltaversion] ([latestdelta], [hash], [filename]) values (99, 'blah-hash', 'whatever file');");
     Assert.AreEqual(1, ExecuteScalar("select count(*) from [dr_deltaversion] where [filename] = 'whatever file'"));
     dataFresh.RefreshTheDatabase();
     Assert.AreEqual(1, ExecuteScalar("select count(*) from [dr_deltaversion] where [filename] = 'whatever file'"));
 }
コード例 #12
0
 public void RefreshTheDatabaseSpeedTests()
 {
     SqlDataFresh dataFresh = new SqlDataFresh(connectionString, true);
     dataFresh.RemoveDataFreshFromDatabase();
     dataFresh.PrepareDatabaseforDataFresh(true);
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
     ExecuteNonQuery("insert into author (lastname, firstname) values ('brockey', 'mike');");
     dataFresh.RefreshTheDatabase();
 }
コード例 #13
0
 public void PrepDatabaseforDataFresh_NoConnectionString()
 {
     SqlDataFresh dataFresh = new SqlDataFresh(null);
     dataFresh.PrepareDatabaseforDataFresh();
 }
コード例 #14
0
        public void Start(string[] args)
        {
            ConsoleWrite("DataFresh provided by Entropy Zero Consulting");

            if (args == null || args.Length < 2)
            {
                WriteUsage();
                return;
            }

            for (int i = 0; i < args.Length; i = i + 2)
            {
                this.arguments.Add(args[i].Replace("-", ""), args[i + 1]);
                //ConsoleWrite(args[i] + ": " +args[i+1]);
            }

            if (!CheckForRequiredArguments(this.arguments))
            {
                return;
            }

            connectionString = string.Format(@"user id={0};password={1};Initial Catalog={2};Data Source={3};",
                                             this.arguments["u"],
                                             this.arguments["p"],
                                             this.arguments["d"],
                                             this.arguments["s"]);

            SqlDataFresh dataFresh = new SqlDataFresh(connectionString, true);

            string snapshotPath = this.arguments["sp"];

            if (snapshotPath != null)
            {
                snapshotPath = snapshotPath.Replace("\"", "");
                if (!snapshotPath.EndsWith(@"\"))
                {
                    snapshotPath += @"\";
                }

                ConsoleWrite("snapshotPath = {0}", snapshotPath);
                string fullPath = Path.GetFullPath(snapshotPath);
                ConsoleWrite("fullPath = {0}", fullPath);
                dataFresh.SnapshotPath = new DirectoryInfo(snapshotPath);
            }

            string command = this.arguments["c"].ToUpper();
            switch (command)
            {
                case "PREPARE":
                    bool ignoreSnapshot = false;
                    string ignoreSnapshotArgument = arguments["ignoresnapshot"];
                    if(ignoreSnapshotArgument != null)
                    {
                        if(ignoreSnapshotArgument == "1")
                        {
                            ignoreSnapshot = true;
                        }
                    }
                    dataFresh.PrepareDatabaseforDataFresh(!ignoreSnapshot);
                    break;
                case "REFRESH":
                    dataFresh.RefreshTheDatabase();
                    break;
                case "FORCEREFRESH":
                    dataFresh.RefreshTheEntireDatabase();
                    break;
                case "REMOVE":
                    dataFresh.RemoveDataFreshFromDatabase();
                    break;
                case "SNAPSHOT":
                    dataFresh.CreateSnapshot();
                    break;
                case "FOO":
                    //no nothing
                    break;
                default:
                    ConsoleWrite("Command '{0}' was not recognized", command);
                    break;
            }
        }