public virtual void TestParse_AddNoNewline() { NGit.Patch.Patch p = ParseTestPatchFile(); NUnit.Framework.Assert.AreEqual(1, p.GetFiles().Count); NUnit.Framework.Assert.IsTrue(p.GetErrors().IsEmpty()); FileHeader f = p.GetFiles()[0]; NUnit.Framework.Assert.AreEqual("a", f.GetNewPath()); NUnit.Framework.Assert.AreEqual(256, f.startOffset); NUnit.Framework.Assert.AreEqual("f2ad6c7", f.GetOldId().Name); NUnit.Framework.Assert.AreEqual("c59d9b6", f.GetNewId().Name); NUnit.Framework.Assert.AreEqual(FileHeader.PatchType.UNIFIED, f.GetPatchType()); NUnit.Framework.Assert.AreSame(FileMode.REGULAR_FILE, f.GetOldMode()); NUnit.Framework.Assert.AreSame(FileMode.REGULAR_FILE, f.GetNewMode()); NUnit.Framework.Assert.AreEqual(1, f.GetHunks().Count); { HunkHeader h = f.GetHunks()[0]; NUnit.Framework.Assert.AreSame(f, h.GetFileHeader()); NUnit.Framework.Assert.AreEqual(321, h.startOffset); NUnit.Framework.Assert.AreEqual(1, h.GetOldImage().GetStartLine()); NUnit.Framework.Assert.AreEqual(1, h.GetOldImage().GetLineCount()); NUnit.Framework.Assert.AreEqual(1, h.GetNewStartLine()); NUnit.Framework.Assert.AreEqual(1, h.GetNewLineCount()); NUnit.Framework.Assert.AreEqual(0, h.GetLinesContext()); NUnit.Framework.Assert.AreEqual(1, h.GetOldImage().GetLinesAdded()); NUnit.Framework.Assert.AreEqual(1, h.GetOldImage().GetLinesDeleted()); NUnit.Framework.Assert.AreSame(f.GetOldId(), h.GetOldImage().GetId()); NUnit.Framework.Assert.AreEqual(367, h.endOffset); } }
internal virtual void AddHunk(HunkHeader h) { if (h.GetFileHeader() != this) { throw new ArgumentException(JGitText.Get().hunkBelongsToAnotherFile); } if (hunks == null) { hunks = new AList <HunkHeader>(); } hunks.AddItem(h); }
internal virtual void AddHunk(HunkHeader h) { if (h.GetFileHeader() != this) { throw new ArgumentException(JGitText.Get().hunkBelongsToAnotherFile); } if (hunks == null) { hunks = new AList<HunkHeader>(); } hunks.AddItem(h); }
public virtual void TestParse_ConfigCaseInsensitive() { NGit.Patch.Patch p = ParseTestPatchFile(); NUnit.Framework.Assert.AreEqual(2, p.GetFiles().Count); NUnit.Framework.Assert.IsTrue(p.GetErrors().IsEmpty()); FileHeader fRepositoryConfigTest = p.GetFiles()[0]; FileHeader fRepositoryConfig = p.GetFiles()[1]; NUnit.Framework.Assert.AreEqual("org.eclipse.jgit.test/tst/org/spearce/jgit/lib/RepositoryConfigTest.java" , fRepositoryConfigTest.GetNewPath()); NUnit.Framework.Assert.AreEqual("org.eclipse.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java" , fRepositoryConfig.GetNewPath()); NUnit.Framework.Assert.AreEqual(572, fRepositoryConfigTest.startOffset); NUnit.Framework.Assert.AreEqual(1490, fRepositoryConfig.startOffset); NUnit.Framework.Assert.AreEqual("da7e704", fRepositoryConfigTest.GetOldId().Name); NUnit.Framework.Assert.AreEqual("34ce04a", fRepositoryConfigTest.GetNewId().Name); NUnit.Framework.Assert.AreEqual(FileHeader.PatchType.UNIFIED, fRepositoryConfigTest .GetPatchType()); NUnit.Framework.Assert.AreSame(FileMode.REGULAR_FILE, fRepositoryConfigTest.GetOldMode ()); NUnit.Framework.Assert.AreSame(FileMode.REGULAR_FILE, fRepositoryConfigTest.GetNewMode ()); NUnit.Framework.Assert.AreEqual(1, fRepositoryConfigTest.GetHunks().Count); { HunkHeader h = fRepositoryConfigTest.GetHunks()[0]; NUnit.Framework.Assert.AreSame(fRepositoryConfigTest, h.GetFileHeader()); NUnit.Framework.Assert.AreEqual(921, h.startOffset); NUnit.Framework.Assert.AreEqual(109, h.GetOldImage().GetStartLine()); NUnit.Framework.Assert.AreEqual(4, h.GetOldImage().GetLineCount()); NUnit.Framework.Assert.AreEqual(109, h.GetNewStartLine()); NUnit.Framework.Assert.AreEqual(11, h.GetNewLineCount()); NUnit.Framework.Assert.AreEqual(4, h.GetLinesContext()); NUnit.Framework.Assert.AreEqual(7, h.GetOldImage().GetLinesAdded()); NUnit.Framework.Assert.AreEqual(0, h.GetOldImage().GetLinesDeleted()); NUnit.Framework.Assert.AreSame(fRepositoryConfigTest.GetOldId(), h.GetOldImage(). GetId()); NUnit.Framework.Assert.AreEqual(1490, h.endOffset); } NUnit.Framework.Assert.AreEqual("45c2f8a", fRepositoryConfig.GetOldId().Name); NUnit.Framework.Assert.AreEqual("3291bba", fRepositoryConfig.GetNewId().Name); NUnit.Framework.Assert.AreEqual(FileHeader.PatchType.UNIFIED, fRepositoryConfig.GetPatchType ()); NUnit.Framework.Assert.AreSame(FileMode.REGULAR_FILE, fRepositoryConfig.GetOldMode ()); NUnit.Framework.Assert.AreSame(FileMode.REGULAR_FILE, fRepositoryConfig.GetNewMode ()); NUnit.Framework.Assert.AreEqual(3, fRepositoryConfig.GetHunks().Count); { HunkHeader h = fRepositoryConfig.GetHunks()[0]; NUnit.Framework.Assert.AreSame(fRepositoryConfig, h.GetFileHeader()); NUnit.Framework.Assert.AreEqual(1803, h.startOffset); NUnit.Framework.Assert.AreEqual(236, h.GetOldImage().GetStartLine()); NUnit.Framework.Assert.AreEqual(9, h.GetOldImage().GetLineCount()); NUnit.Framework.Assert.AreEqual(236, h.GetNewStartLine()); NUnit.Framework.Assert.AreEqual(9, h.GetNewLineCount()); NUnit.Framework.Assert.AreEqual(7, h.GetLinesContext()); NUnit.Framework.Assert.AreEqual(2, h.GetOldImage().GetLinesAdded()); NUnit.Framework.Assert.AreEqual(2, h.GetOldImage().GetLinesDeleted()); NUnit.Framework.Assert.AreSame(fRepositoryConfig.GetOldId(), h.GetOldImage().GetId ()); NUnit.Framework.Assert.AreEqual(2434, h.endOffset); } { HunkHeader h = fRepositoryConfig.GetHunks()[1]; NUnit.Framework.Assert.AreEqual(2434, h.startOffset); NUnit.Framework.Assert.AreEqual(300, h.GetOldImage().GetStartLine()); NUnit.Framework.Assert.AreEqual(7, h.GetOldImage().GetLineCount()); NUnit.Framework.Assert.AreEqual(300, h.GetNewStartLine()); NUnit.Framework.Assert.AreEqual(7, h.GetNewLineCount()); NUnit.Framework.Assert.AreEqual(6, h.GetLinesContext()); NUnit.Framework.Assert.AreEqual(1, h.GetOldImage().GetLinesAdded()); NUnit.Framework.Assert.AreEqual(1, h.GetOldImage().GetLinesDeleted()); NUnit.Framework.Assert.AreEqual(2816, h.endOffset); } { HunkHeader h = fRepositoryConfig.GetHunks()[2]; NUnit.Framework.Assert.AreEqual(2816, h.startOffset); NUnit.Framework.Assert.AreEqual(954, h.GetOldImage().GetStartLine()); NUnit.Framework.Assert.AreEqual(7, h.GetOldImage().GetLineCount()); NUnit.Framework.Assert.AreEqual(954, h.GetNewStartLine()); NUnit.Framework.Assert.AreEqual(7, h.GetNewLineCount()); NUnit.Framework.Assert.AreEqual(6, h.GetLinesContext()); NUnit.Framework.Assert.AreEqual(1, h.GetOldImage().GetLinesAdded()); NUnit.Framework.Assert.AreEqual(1, h.GetOldImage().GetLinesDeleted()); NUnit.Framework.Assert.AreEqual(3035, h.endOffset); } }