private bool TryGetArtifactsBaseDirectory(SqlProject project,
                                                  ConfigurationModel configuration,
                                                  out string artifactsBaseDirectory)
        {
            var projectPath      = project.FullName;
            var projectDirectory = Path.GetDirectoryName(projectPath);

            if (projectDirectory == null)
            {
                _visualStudioAccess.ShowModalError("ERROR: Cannot determine project directory.");
                artifactsBaseDirectory = null;
                return(false);
            }

            var artifactPathErrors = ConfigurationModelValidations.ValidateArtifactsPath(configuration);

            if (artifactPathErrors.Any())
            {
                _visualStudioAccess.ShowModalError("ERROR: The configured artifacts path is not valid. Please ensure that the configuration is correct.");
                artifactsBaseDirectory = null;
                return(false);
            }

            artifactsBaseDirectory = Path.Combine(projectDirectory, configuration.ArtifactsPath);
            return(true);
        }
Beispiel #2
0
        public void ValidateVersionPattern_NoErrors(string pattern)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = pattern
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(0, errors.Count);
        }
Beispiel #3
0
        public void ValidateArtifactsPath_NoErrors()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                ArtifactsPath = @"..\_Deployment"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateArtifactsPath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(0, errors.Count);
        }
Beispiel #4
0
        public void ValidateSharedDacpacRepositoryPath_NoErrors()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                SharedDacpacRepositoryPath = @"C:\Test\Repository\"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateSharedDacpacRepositoryPath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(0, errors.Count);
        }
Beispiel #5
0
        public void ValidateSharedDacpacRepositoryPath_NoErrors_EmptyPath(string path)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                SharedDacpacRepositoryPath = path
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateSharedDacpacRepositoryPath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(0, errors.Count);
        }
Beispiel #6
0
        public void ValidatePublishProfilePath_NoErrors(string publishProfilePath)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                PublishProfilePath = publishProfilePath
            };

            // Act
            var errors = ConfigurationModelValidations.ValidatePublishProfilePath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(0, errors.Count);
        }
Beispiel #7
0
        public void ValidateVersionPattern_Errors_EmptyPattern(string pattern)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = pattern
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Pattern cannot be empty.", errors[0]);
        }
Beispiel #8
0
        public void ValidatePublishProfilePath_Errors_NoRelativePath()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                PublishProfilePath = @"C:\Temp\Database.publish.xml"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidatePublishProfilePath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Path must be a relative path.", errors[0]);
        }
Beispiel #9
0
        public void ValidateSharedDacpacRepositoryPath_Errors_NoAbsolutePath()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                SharedDacpacRepositoryPath = @"..\Repository"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateSharedDacpacRepositoryPath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Path must be an absolute path.", errors[0]);
        }
Beispiel #10
0
        public void ValidateArtifactsPath_Errors_EmptyPath(string path)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                ArtifactsPath = path
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateArtifactsPath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Path cannot be empty.", errors[0]);
        }
Beispiel #11
0
        public void ValidateSharedDacpacRepositoryPath_Errors_MustBeDirectory(string path)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                SharedDacpacRepositoryPath = path
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateSharedDacpacRepositoryPath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Path must be a directory.", errors[0]);
        }
Beispiel #12
0
        public void ValidateSharedDacpacRepositoryPath_Errors_InvalidCharacters()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                SharedDacpacRepositoryPath = "C:\\" + new string(Path.GetInvalidPathChars()) + "\\Test\\"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateSharedDacpacRepositoryPath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Path contains invalid characters.", errors[0]);
        }
Beispiel #13
0
        public void ValidateVersionPattern_Errors_PatternTooLong(string pattern)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = pattern
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Pattern contains too many parts.", errors[0]);
        }
Beispiel #14
0
        public void ValidateUnnamedDefaultConstraintDropsBehavior_NoErrors(bool commentOut, bool replace)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                CommentOutUnnamedDefaultConstraintDrops = commentOut,
                ReplaceUnnamedDefaultConstraintDrops    = replace
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateUnnamedDefaultConstraintDropsBehavior(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(0, errors.Count);
        }
Beispiel #15
0
        [TestCase("Database.pub.xml")] // Wrong ending is not OK.
        public void ValidatePublishProfilePath_Errors_DoesNotEndCorrectly(string path)
        {
            // Arrange
            var model = new ConfigurationModel
            {
                PublishProfilePath = path
            };

            // Act
            var errors = ConfigurationModelValidations.ValidatePublishProfilePath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Profile file name must end with *.publish.xml.", errors[0]);
        }
Beispiel #16
0
        public void ValidateArtifactsPath_Errors_NoRelativePath()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                ArtifactsPath = @"C:\Temp\_Deployment"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateArtifactsPath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Path must be a relative path.", errors[0]);
        }
Beispiel #17
0
        public void ValidateArtifactsPath_Errors_InvalidCharacters()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                ArtifactsPath = new string(Path.GetInvalidPathChars())
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateArtifactsPath(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Path contains invalid characters.", errors[0]);
        }
Beispiel #18
0
        public void ValidateUnnamedDefaultConstraintDropsBehavior_Errors_BothSetToTrue()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                CommentOutUnnamedDefaultConstraintDrops = true,
                ReplaceUnnamedDefaultConstraintDrops    = true
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateUnnamedDefaultConstraintDropsBehavior(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Behavior for unnamed default constraint drops is ambiguous.", errors[0]);
        }
Beispiel #19
0
        public void ValidateVersionPattern_Errors_InvalidSpecialKeywords()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = "{REVISION}.{BUILD}.{MINOR}.{MAJOR}"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(4, errors.Count);
            Assert.AreEqual("Invalid special keyword for major number.", errors[0]);
            Assert.AreEqual("Invalid special keyword for minor number.", errors[1]);
            Assert.AreEqual("Invalid special keyword for build number.", errors[2]);
            Assert.AreEqual("Invalid special keyword for revision number.", errors[3]);
        }
Beispiel #20
0
        public void ValidateVersionPattern_Errors_NegativeNumbers()
        {
            // Arrange
            var model = new ConfigurationModel
            {
                VersionPattern = "-1.-1.-1.-1"
            };

            // Act
            var errors = ConfigurationModelValidations.ValidateVersionPattern(model);

            // Assert
            Assert.IsNotNull(errors);
            Assert.AreEqual(4, errors.Count);
            Assert.AreEqual("Major number cannot be negative.", errors[0]);
            Assert.AreEqual("Minor number cannot be negative.", errors[1]);
            Assert.AreEqual("Build number cannot be negative.", errors[2]);
            Assert.AreEqual("Revision number cannot be negative.", errors[3]);
        }
Beispiel #21
0
 public void ValidatePublishProfilePath_ArgumentNullException_Model()
 {
     // Act & Assert
     // ReSharper disable once AssignNullToNotNullAttribute
     Assert.Throws <ArgumentNullException>(() => ConfigurationModelValidations.ValidatePublishProfilePath(null));
 }
Beispiel #22
0
 public void ValidateUnnamedDefaultConstraintDropsBehavior_ArgumentNullException_Model()
 {
     // Act & Assert
     // ReSharper disable once AssignNullToNotNullAttribute
     Assert.Throws <ArgumentNullException>(() => ConfigurationModelValidations.ValidateUnnamedDefaultConstraintDropsBehavior(null));
 }