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 ConsolidateProjectFilePath_Should_Convert_Relative_Paths_To_Absolute_Paths() { // Arrange: var helper = new ProjectPathHelper(Mock.Of<IFileSystem>()); // Act: string result = helper.ConsolidateProjectFilePath("dev|test.sln".Path()); // Assert: Assert.AreEqual(Path.Combine(Environment.CurrentDirectory, "dev|test.sln".Path()), result); }
public void ConsolidateProjectFilePath_Should_Not_Alter_Absolute_Paths() { // Arrange: var helper = new ProjectPathHelper(Mock.Of<IFileSystem>()); // Act: string result = helper.ConsolidateProjectFilePath("|dev|test.sln".Path()); // Assert: Assert.AreEqual("|dev|test.sln".Path(), result); }