public void PackageSbxFilesIntoSbmFilesTest_SingleSbx()
        {
            string directoryName = Path.GetTempPath() + Guid.NewGuid().ToString();

            Directory.CreateDirectory(directoryName);

            string sbxBuildControlFileName = Path.Combine(directoryName, "sbx_package_tester.sbx");
            string script1 = Path.Combine(directoryName, "CreateTestTablesScript.sql");
            string script2 = Path.Combine(directoryName, "LoggingTable.sql");

            File.WriteAllBytes(sbxBuildControlFileName, Properties.Resources.sbx_package_tester);
            File.WriteAllText(script1, Properties.Resources.CreateTestTablesScript);
            File.WriteAllText(script2, Properties.Resources.LoggingTable);

            string message         = string.Empty;
            string messageExpected = string.Empty;

            List <string> actual;

            actual = SqlBuildFileHelper.PackageSbxFilesIntoSbmFiles(directoryName, out message);
            Directory.Delete(directoryName, true);
            Assert.AreEqual(messageExpected, message);
            Assert.AreEqual(1, actual.Count);
            Assert.IsTrue(actual[0] == Path.Combine(directoryName, "sbx_package_tester.sbm"));
        }
        public void PackageSbxFilesIntoSbmFilesTest_FailDirectoryDoesntExist()
        {
            string directoryName = @"C:\" + Guid.NewGuid().ToString();

            string        message;
            string        messageExpected = String.Format("Unable to package SBX files. The specified source directory '{0}' does not exist.", directoryName);
            List <string> actual;

            actual = SqlBuildFileHelper.PackageSbxFilesIntoSbmFiles(directoryName, out message);

            Assert.AreEqual(messageExpected, message);
            Assert.AreEqual(0, actual.Count);
        }
        public void PackageSbxFilesIntoSbmFilesTest_FailDirectoryIsEmptyString()
        {
            string directoryName = String.Empty;

            string        message;
            string        messageExpected = "Unable to package SBX files. Source directory parameter is empty";
            List <string> actual;

            actual = SqlBuildFileHelper.PackageSbxFilesIntoSbmFiles(directoryName, out message);

            Assert.AreEqual(messageExpected, message);
            Assert.AreEqual(0, actual.Count);
        }
        public void PackageSbxFilesIntoSbmFilesTest_FailNoSbx()
        {
            string directoryName = Path.GetTempPath() + Guid.NewGuid().ToString();

            Directory.CreateDirectory(directoryName);

            string message         = string.Empty;
            string messageExpected = String.Format("No SBX files found in source directory '{0}' or any of it's subdirectories", directoryName);

            List <string> actual;

            actual = SqlBuildFileHelper.PackageSbxFilesIntoSbmFiles(directoryName, out message);
            Directory.Delete(directoryName, true);
            Assert.AreEqual(messageExpected, message);
            Assert.AreEqual(0, actual.Count);
        }
        public void PackageSbxFilesIntoSbmFilesTest_FailBadSbx()
        {
            string directoryName = Path.GetTempPath() + Guid.NewGuid().ToString();

            Directory.CreateDirectory(directoryName);

            string sbxBuildControlFileName = Path.Combine(directoryName, "sbx_package_tester.sbx");

            File.WriteAllText(sbxBuildControlFileName, "bad contents");
            string message         = string.Empty;
            string messageExpected = string.Empty;

            List <string> actual;

            actual = SqlBuildFileHelper.PackageSbxFilesIntoSbmFiles(directoryName, out message);
            Directory.Delete(directoryName, true);
            Assert.IsTrue(message.StartsWith("Error packaging SBX file"));
            Assert.AreEqual(0, actual.Count);
        }