public void CalculateBuildPackageSHA1_CompareMethodologyTest()
        {
            //Set up directory and files...
            string projectFileExtractionPath = Path.GetTempPath() + Guid.NewGuid().ToString() + "\\";

            if (!Directory.Exists(projectFileExtractionPath))
            {
                Directory.CreateDirectory(projectFileExtractionPath);
            }

            string file1 = "File1.sql";

            File.WriteAllText(projectFileExtractionPath + file1, Properties.Resources.CreateDatabaseScript);

            string file2 = "File2.sql";

            File.WriteAllText(projectFileExtractionPath + file2, Properties.Resources.CreateTestTablesScript);

            string file3 = "File3.sql";

            File.WriteAllText(projectFileExtractionPath + file3, Properties.Resources.LoggingTable);


            SqlSyncBuildData buildData = SqlBuildFileHelper.CreateShellSqlSyncBuildDataObject();

            SqlSyncBuildData.ScriptRow row1 = buildData.Script.NewScriptRow();
            row1.BuildOrder           = 1;
            row1.FileName             = file1;
            row1.StripTransactionText = true;

            SqlSyncBuildData.ScriptRow row2 = buildData.Script.NewScriptRow();
            row2.BuildOrder           = 2;
            row2.FileName             = file2;
            row2.StripTransactionText = true;

            SqlSyncBuildData.ScriptRow row3 = buildData.Script.NewScriptRow();
            row3.BuildOrder           = 3;
            row3.FileName             = file3;
            row3.StripTransactionText = true;

            buildData.Script.Rows.Add(row1);
            buildData.Script.Rows.Add(row2);
            buildData.Script.Rows.Add(row3);


            string fromPath = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);


            ScriptBatchCollection batch = SqlBuildHelper.LoadAndBatchSqlScripts(buildData, projectFileExtractionPath);
            string fromBatch            = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromBatchCollection(batch);

            if (Directory.Exists(projectFileExtractionPath))
            {
                Directory.Delete(projectFileExtractionPath, true);
            }

            Assert.AreEqual(fromPath, fromBatch);
        }
        public void CalculateBuildPackageSHA1SignatureFromPathTest_GetHashSuccessfully()
        {
            //Set up directory and files...
            string projectFileExtractionPath = Path.GetTempPath() + Guid.NewGuid().ToString() + "\\";

            if (!Directory.Exists(projectFileExtractionPath))
            {
                Directory.CreateDirectory(projectFileExtractionPath);
            }

            string file1 = "File1.sql";

            File.WriteAllText(projectFileExtractionPath + file1, Properties.Resources.CreateDatabaseScript);

            string file2 = "File2.sql";

            File.WriteAllText(projectFileExtractionPath + file2, Properties.Resources.CreateTestTablesScript);

            string file3 = "File3.sql";

            File.WriteAllText(projectFileExtractionPath + file3, Properties.Resources.LoggingTable);


            SqlSyncBuildData buildData = SqlBuildFileHelper.CreateShellSqlSyncBuildDataObject();

            SqlSyncBuildData.ScriptRow row1 = buildData.Script.NewScriptRow();
            row1.BuildOrder = 1;
            row1.FileName   = file1;

            SqlSyncBuildData.ScriptRow row2 = buildData.Script.NewScriptRow();
            row2.BuildOrder = 2;
            row2.FileName   = file2;

            SqlSyncBuildData.ScriptRow row3 = buildData.Script.NewScriptRow();
            row3.BuildOrder = 3;
            row3.FileName   = file3;

            buildData.Script.Rows.Add(row1);
            buildData.Script.Rows.Add(row2);
            buildData.Script.Rows.Add(row3);

            string expected = "4E0F54A4BA40DC62A78822B20C7D83713CE4F766";
            string actual;

            actual = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);

            if (Directory.Exists(projectFileExtractionPath))
            {
                Directory.Delete(projectFileExtractionPath, true);
            }

            Assert.AreEqual(expected, actual);
        }
        public void CalculateBuildPackageSHA1_CompareMethodologyTest_OrderCheckingWithTransactionsToRemove()
        {
            //Set up directory and files...
            string projectFileExtractionPath = Path.GetTempPath() + Guid.NewGuid().ToString() + "\\";

            if (!Directory.Exists(projectFileExtractionPath))
            {
                Directory.CreateDirectory(projectFileExtractionPath);
            }

            string file1 = "File1.sql";

            File.WriteAllText(projectFileExtractionPath + file1, @"This is My script
with my 
COMMIT TRANS
test");

            string file2 = "File2.sql";

            File.WriteAllText(projectFileExtractionPath + file2, Properties.Resources.CreateTestTablesScript);

            string file3 = "File3.sql";

            File.WriteAllText(projectFileExtractionPath + file3, @"This is another test that has
--ROLLBACK TRANSACTION
where the 
BEGIN TRAN
needs to be removed");


            SqlSyncBuildData buildData = SqlBuildFileHelper.CreateShellSqlSyncBuildDataObject();

            SqlSyncBuildData.ScriptRow row1 = buildData.Script.NewScriptRow();
            row1.BuildOrder           = 1;
            row1.FileName             = file1;
            row1.StripTransactionText = true;

            SqlSyncBuildData.ScriptRow row2 = buildData.Script.NewScriptRow();
            row2.BuildOrder           = 2;
            row2.FileName             = file2;
            row2.StripTransactionText = true;

            SqlSyncBuildData.ScriptRow row3 = buildData.Script.NewScriptRow();
            row3.BuildOrder           = 3;
            row3.FileName             = file3;
            row3.StripTransactionText = true;

            buildData.Script.Rows.Add(row1);
            buildData.Script.Rows.Add(row2);
            buildData.Script.Rows.Add(row3);


            string fromPath123 = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);

            ScriptBatchCollection batch = SqlBuildHelper.LoadAndBatchSqlScripts(buildData, projectFileExtractionPath);
            string fromBatch123         = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromBatchCollection(batch);

            buildData.Script[0].BuildOrder = 2;
            buildData.Script[1].BuildOrder = 1;
            buildData.Script[2].BuildOrder = 3;
            buildData.AcceptChanges();

            string fromPath213 = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);

            batch = SqlBuildHelper.LoadAndBatchSqlScripts(buildData, projectFileExtractionPath);
            string fromBatch213 = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromBatchCollection(batch);


            if (Directory.Exists(projectFileExtractionPath))
            {
                Directory.Delete(projectFileExtractionPath, true);
            }

            Assert.AreEqual(fromPath123, fromBatch123);
            Assert.AreEqual(fromPath213, fromBatch213);
            Assert.AreNotEqual(fromPath123, fromBatch213);
            Assert.AreNotEqual(fromPath213, fromBatch123);
        }
        public void CalculateBuildPackageSHA1SignatureFromPathTest_BuildOrderSwitch()
        {
            //Set up directory and files...
            string projectFileExtractionPath = Path.GetTempPath() + Guid.NewGuid().ToString() + "\\";

            if (!Directory.Exists(projectFileExtractionPath))
            {
                Directory.CreateDirectory(projectFileExtractionPath);
            }

            string file1 = "File1.sql";

            File.WriteAllText(projectFileExtractionPath + file1, Properties.Resources.CreateDatabaseScript);

            string file2 = "File2.sql";

            File.WriteAllText(projectFileExtractionPath + file2, Properties.Resources.CreateTestTablesScript);

            string file3 = "File3.sql";

            File.WriteAllText(projectFileExtractionPath + file3, Properties.Resources.LoggingTable);


            SqlSyncBuildData buildData = SqlBuildFileHelper.CreateShellSqlSyncBuildDataObject();

            SqlSyncBuildData.ScriptRow row1 = buildData.Script.NewScriptRow();
            row1.BuildOrder = 1;
            row1.FileName   = file1;

            SqlSyncBuildData.ScriptRow row2 = buildData.Script.NewScriptRow();
            row2.BuildOrder = 2;
            row2.FileName   = file2;

            SqlSyncBuildData.ScriptRow row3 = buildData.Script.NewScriptRow();
            row3.BuildOrder = 3;
            row3.FileName   = file3;

            buildData.Script.Rows.Add(row1);
            buildData.Script.Rows.Add(row2);
            buildData.Script.Rows.Add(row3);

            string order123 = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);

            buildData.Script[0].BuildOrder = 1;
            buildData.Script[1].BuildOrder = 3;
            buildData.Script[2].BuildOrder = 2;
            buildData.AcceptChanges();

            string order132 = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);

            buildData.Script[0].BuildOrder = 2;
            buildData.Script[1].BuildOrder = 1;
            buildData.Script[2].BuildOrder = 3;
            buildData.AcceptChanges();

            string order213 = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);

            buildData.Script[0].BuildOrder = 2;
            buildData.Script[1].BuildOrder = 3;
            buildData.Script[2].BuildOrder = 1;
            buildData.AcceptChanges();

            string order231 = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);

            buildData.Script[0].BuildOrder = 3;
            buildData.Script[1].BuildOrder = 1;
            buildData.Script[2].BuildOrder = 2;
            buildData.AcceptChanges();

            string order312 = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);

            buildData.Script[0].BuildOrder = 3;
            buildData.Script[1].BuildOrder = 2;
            buildData.Script[2].BuildOrder = 1;
            buildData.AcceptChanges();

            string order321 = SqlBuildFileHelper.CalculateBuildPackageSHA1SignatureFromPath(projectFileExtractionPath, buildData);

            if (Directory.Exists(projectFileExtractionPath))
            {
                Directory.Delete(projectFileExtractionPath, true);
            }

            Assert.AreNotEqual(order123, order132);
            Assert.AreNotEqual(order123, order213);
            Assert.AreNotEqual(order123, order231);
            Assert.AreNotEqual(order123, order312);
            Assert.AreNotEqual(order312, order321);

            Assert.AreNotEqual(order132, order213);
            Assert.AreNotEqual(order132, order231);
            Assert.AreNotEqual(order132, order312);
            Assert.AreNotEqual(order132, order321);

            Assert.AreNotEqual(order213, order231);
            Assert.AreNotEqual(order213, order312);
            Assert.AreNotEqual(order213, order321);

            Assert.AreNotEqual(order231, order312);
            Assert.AreNotEqual(order231, order321);

            Assert.AreNotEqual(order231, order321);
        }