Exemplo n.º 1
0
        public virtual void TestGetText_NoBinary()
        {
            Encoding cs = Sharpen.Extensions.GetEncoding("ISO-8859-1");

            NGit.Patch.Patch p = ParseTestPatchFile();
            NUnit.Framework.Assert.IsTrue(p.GetErrors().IsEmpty());
            NUnit.Framework.Assert.AreEqual(1, p.GetFiles().Count);
            FileHeader fh = p.GetFiles()[0];

            NUnit.Framework.Assert.AreEqual(0, fh.GetHunks().Count);
            NUnit.Framework.Assert.AreEqual(ReadTestPatchFile(cs), fh.GetScriptText(cs, cs));
        }
Exemplo n.º 2
0
        public virtual void TestGetText_Convert()
        {
            Encoding csOld = Sharpen.Extensions.GetEncoding("ISO-8859-1");
            Encoding csNew = Sharpen.Extensions.GetEncoding("UTF-8");

            NGit.Patch.Patch p = ParseTestPatchFile();
            NUnit.Framework.Assert.IsTrue(p.GetErrors().IsEmpty());
            NUnit.Framework.Assert.AreEqual(1, p.GetFiles().Count);
            FileHeader fh = p.GetFiles()[0];

            NUnit.Framework.Assert.AreEqual(2, fh.GetHunks().Count);
            // Read the original file as ISO-8859-1 and fix up the one place
            // where we changed the character encoding. That makes the exp
            // string match what we really expect to get back.
            //
            string exp = ReadTestPatchFile(csOld);

            exp = exp.Replace("\x12f\xcdngstr\x12f\x10am", "\u00c5ngstr\u00f6m");
            NUnit.Framework.Assert.AreEqual(exp, fh.GetScriptText(csOld, csNew));
        }