ValidateProjectFilePath() public method

public ValidateProjectFilePath ( string projectFile ) : bool
projectFile string
return bool
Ejemplo n.º 1
0
        public void SetVersion(string projectPath, string defaultVersion, string additionalInfo)
        {
            // Validate project path:
            var helper = new ProjectPathHelper(this.fileSystem);
            projectPath = helper.ConsolidateProjectFilePath(projectPath);
            if (!helper.ValidateProjectFilePath(projectPath))
            {
                throw new ArgumentException("The project file is not a valid solution or project file path.", "projectPath");
            }

            // Validate default version:
            Version parsedDefaultVersion;
            if (!Version.TryParse(defaultVersion, out parsedDefaultVersion))
            {
                throw new ArgumentException("The default version has an invalid format.", "defaultVersion");
            }

            // Consolidate additional info:
            if (string.IsNullOrWhiteSpace(additionalInfo))
            {
                additionalInfo = null;
            }

            // Execute:
            if (projectPath.ToLowerInvariant().EndsWith(".sln"))
            {
                SetVersionForSolution(projectPath, parsedDefaultVersion, additionalInfo);
            }
            else
            {
                SetVersionForProject(projectPath, parsedDefaultVersion, additionalInfo);
            }
        }
        public void ValidateProjectFilePath_Should_Return_False_In_Case_Of_Invalid_Paths()
        {
            // Arrange:
            var helper = new ProjectPathHelper(Mock.Of<IFileSystem>());

            // Act:
            var result = helper.ValidateProjectFilePath(@"ABC!§$%&()");

            // Assert:
            Assert.IsFalse(result);
        }