Пример #1
0
        public void EncodeLine_Backslashes()
        {
            byte[] line = TempSFFileMaker.EncodeLine("abc" + @"\\" + "def", Encoding.ASCII);
            Assert.AreEqual(10, line.Length);
            int i = 0;

            Assert.AreEqual('a', line[i++]);
            Assert.AreEqual('b', line[i++]);
            Assert.AreEqual('c', line[i++]);
            Assert.AreEqual('\\', line[i++]);
            Assert.AreEqual('\\', line[i++]);
            Assert.AreEqual('d', line[i++]);
            Assert.AreEqual('e', line[i++]);
            Assert.AreEqual('f', line[i++]);
            Assert.AreEqual(s_cr, line[i++]);
            Assert.AreEqual(s_lf, line[i++]);

            TempSFFileMaker testFileMaker = new TempSFFileMaker();
            string          filename      = testFileMaker.CreateFile("EPH", new[] { @"\v 1 c:\abc\def" }, Encoding.UTF8, false);

            using (TextReader reader = FileUtils.OpenFileForRead(filename, Encoding.UTF8))
            {
                Assert.AreEqual(@"\id EPH", reader.ReadLine());
                Assert.AreEqual(@"\v 1 c:\abc\def", reader.ReadLine());
            }
        }
Пример #2
0
        public void TestCreateFile_UnicodeBOM()
        {
            TempSFFileMaker testFileMaker = new TempSFFileMaker();
            string          filename      = testFileMaker.CreateFile("EPH", null, Encoding.Unicode, true);

            // Check the file contents.
            using (BinaryReader file = FileUtils.OpenFileForBinaryRead(filename, Encoding.Unicode))
            {
                byte[] fileContents = file.ReadBytes((int)file.BaseStream.Length);
                int    i            = 0;
                Assert.AreEqual(0xff, fileContents[i++]);
                Assert.AreEqual(0xfe, fileContents[i++]);
                Assert.AreEqual(92, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(105, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(100, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(32, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(69, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(80, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(72, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(s_cr, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
                Assert.AreEqual(s_lf, fileContents[i++]);
                Assert.AreEqual(0, fileContents[i++]);
            }
        }
Пример #3
0
        public void TestCreateFileThreeLines_ASCII()
        {
            TempSFFileMaker testFileMaker = new TempSFFileMaker();
            string          filename      = testFileMaker.CreateFile("EPH", new string[] { @"\mt test", @"\p" });

            // Check the file contents.
            using (BinaryReader file = FileUtils.OpenFileForBinaryRead(filename, Encoding.ASCII))
            {
                byte[] fileContents = file.ReadBytes((int)file.BaseStream.Length);
                int    i            = 0;
                Assert.AreEqual(92, fileContents[i++]);
                Assert.AreEqual(105, fileContents[i++]);
                Assert.AreEqual(100, fileContents[i++]);
                Assert.AreEqual(32, fileContents[i++]);
                Assert.AreEqual(69, fileContents[i++]);
                Assert.AreEqual(80, fileContents[i++]);
                Assert.AreEqual(72, fileContents[i++]);
                Assert.AreEqual(s_cr, fileContents[i++]);
                Assert.AreEqual(s_lf, fileContents[i++]);

                Assert.AreEqual(92, fileContents[i++]);
                Assert.AreEqual(109, fileContents[i++]);
                Assert.AreEqual(116, fileContents[i++]);
                Assert.AreEqual(32, fileContents[i++]);
                Assert.AreEqual(116, fileContents[i++]);
                Assert.AreEqual(101, fileContents[i++]);
                Assert.AreEqual(115, fileContents[i++]);
                Assert.AreEqual(116, fileContents[i++]);
                Assert.AreEqual(s_cr, fileContents[i++]);
                Assert.AreEqual(s_lf, fileContents[i++]);

                Assert.AreEqual(92, fileContents[i++]);
                Assert.AreEqual(112, fileContents[i++]);
                Assert.AreEqual(s_cr, fileContents[i++]);
                Assert.AreEqual(s_lf, fileContents[i++]);
            }
        }
Пример #4
0
        public void TestCreateFileNullSILBookId()
        {
            TempSFFileMaker testFileMaker = new TempSFFileMaker();

            testFileMaker.CreateFile(null, null);
        }