public void MergeJobFile_IndividualFilePathsForAConflict_WithTestCases(MergeJobConflictSubFile subFile, string expectedPath) { CreateRepositoryWithMergeConflicts(); MergeJob job; try { job = Repo.StartMerge(); } catch (NotSupportedException) { Assert.Inconclusive("Merge tool not supported in this version"); return; } string path = job[0].GetMergeSubFilePath(subFile); Assert.That(path, Is.EqualTo(expectedPath)); path = job[0].GetFullMergeSubFilePath(subFile); expectedPath = Path.Combine(Repo.Path, expectedPath); Assert.That(path, Is.EqualTo(expectedPath)); }
/// <summary> /// Gets the path (local to the repository) of the sub-file present in the working directory /// during the merge, for files with merge-conflicts. /// </summary> /// <param name="subFile"> /// Which particular <see cref="MergeJobConflictSubFile"/> to get the path to. /// </param> /// <returns> /// The path (local to the repository) of the sub-file. /// </returns> /// <exception cref="System.ArgumentException"> /// <para>An invalid <paramref name="subFile"/> value was specified.</para> /// </exception> public string GetMergeSubFilePath(MergeJobConflictSubFile subFile) { switch (subFile) { case MergeJobConflictSubFile.Base: return(string.Format(CultureInfo.InvariantCulture, "{0}.base", Path)); case MergeJobConflictSubFile.Local: return(string.Format(CultureInfo.InvariantCulture, "{0}.local", Path)); case MergeJobConflictSubFile.Other: return(string.Format(CultureInfo.InvariantCulture, "{0}.other", Path)); case MergeJobConflictSubFile.Current: return(Path); default: throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid subFile parameter passed to GetMergeSubFilePath: {0}", subFile)); } }
public void MergeJobFile_IndividualFileContentsForAConflict_WithTestCases(MergeJobConflictSubFile subFile, string expectedContents) { CreateRepositoryWithMergeConflicts(); MergeJob job; try { job = Repo.StartMerge(); } catch (NotSupportedException) { Assert.Inconclusive("Merge tool not supported in this version"); return; } string contents = job[0].GetMergeSubFileContentsAsText(subFile); Assert.That(contents, Is.EqualTo(expectedContents)); }
/// <summary> /// Gets the contents of the sub-file, as an array of <see cref="byte"/>s. /// </summary> /// <param name="subFile"> /// Which particular <see cref="MergeJobConflictSubFile"/> to get the contents of. /// </param> /// <returns> /// The contents of the specified <paramref name="subFile"/>, as an array of <see cref="byte"/>s. /// </returns> public byte[] GetMergeSubFileContentsAsBytes(MergeJobConflictSubFile subFile) { return(File.ReadAllBytes(GetFullMergeSubFilePath(subFile))); }
/// <summary> /// Gets the contents of the sub-file, as a <see cref="string"/>, /// using <see cref="System.Text.Encoding.Default"/> to decode the contents. /// </summary> /// <param name="subFile"> /// Which particular <see cref="MergeJobConflictSubFile"/> to get the contents of. /// </param> /// <returns> /// The contents of the specified <paramref name="subFile"/>, as a <see cref="string"/>. /// </returns> public string GetMergeSubFileContentsAsText(MergeJobConflictSubFile subFile) { return(GetMergeSubFileContentsAsText(subFile, Encoding.Default)); }
/// <summary> /// Gets the contents of the sub-file, as a <see cref="string"/>, using the /// specified <paramref name="encoding"/> to decode the contents. /// </summary> /// <param name="subFile"> /// Which particular <see cref="MergeJobConflictSubFile"/> to get the contents of. /// </param> /// <param name="encoding"> /// The <see cref="System.Text.Encoding"/> to use when reading the file contents; /// or <c>null</c> to use <see cref="System.Text.Encoding.Default"/>. /// </param> /// <returns> /// The contents of the specified <paramref name="subFile"/>, as a <see cref="string"/>. /// </returns> public string GetMergeSubFileContentsAsText(MergeJobConflictSubFile subFile, Encoding encoding) { encoding = encoding ?? Encoding.Default; return(File.ReadAllText(GetFullMergeSubFilePath(subFile), encoding)); }
/// <summary> /// Gets the path (local to the repository) of the sub-file present in the working directory /// during the merge, for files with merge-conflicts. /// </summary> /// <param name="subFile"> /// Which particular <see cref="MergeJobConflictSubFile"/> to get the path to. /// </param> /// <returns> /// The path (local to the repository) of the sub-file. /// </returns> public string GetFullMergeSubFilePath(MergeJobConflictSubFile subFile) { return(System.IO.Path.Combine(MergeJob.Repository.Path, GetMergeSubFilePath(subFile))); }
/// <summary> /// Gets the contents of the sub-file, as a <see cref="String"/>, using the /// specified <paramref name="encoding"/> to decode the contents. /// </summary> /// <param name="subFile"> /// Which particular <see cref="MergeJobConflictSubFile"/> to get the contents of. /// </param> /// <param name="encoding"> /// The <see cref="Encoding"/> to use when reading the file contents; /// or <c>null</c> to use <see cref="Encoding.Default"/>. /// </param> /// <returns> /// The contents of the specified <paramref name="subFile"/>, as a <see cref="String"/>. /// </returns> public string GetMergeSubFileContentsAsText(MergeJobConflictSubFile subFile, Encoding encoding) { encoding = encoding ?? ClientExecutable.TextEncoding; return(File.ReadAllText(GetFullMergeSubFilePath(subFile), encoding)); }