Пример #1
0
        public void WriteStringStringEncodingTest002()
        {
            DjvuWriter writer = null;

            using (MemoryStream stream = new MemoryStream())
                using (writer = new DjvuWriter(stream))
                {
                    string   testString = "";
                    Encoding encoding   = null;
                    Assert.Throws <ArgumentNullException>("encoding", () => writer.WriteString(testString, encoding));
                }
        }
Пример #2
0
        public void WriteStringEncoding_Theory(String testString, Encoding encoding)
        {
            DjvuWriter writer = null;

            using (MemoryStream stream = new MemoryStream())
                using (writer = new DjvuWriter(stream))
                {
                    long   length     = writer.WriteString(testString, encoding);
                    byte[] buffer     = stream.GetBuffer();
                    byte[] testBuffer = new byte[length];
                    Buffer.BlockCopy(buffer, 0, testBuffer, 0, (int)length);
                    string result = encoding.GetString(testBuffer);
                    Assert.Equal(testString, result);
                    Assert.Equal <long>(length, stream.Position);
                    Assert.Equal <long>(stream.Position, writer.Position);
                }
        }