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 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 #3
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 #4
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 #5
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 #6
0
 public void ValidateArtifactsPath_ArgumentNullException_Model()
 {
     // Act & Assert
     // ReSharper disable once AssignNullToNotNullAttribute
     Assert.Throws <ArgumentNullException>(() => ConfigurationModelValidations.ValidateArtifactsPath(null));
 }