Esempio n. 1
0
        public void Should_return_empty_string_when_encoding_empty_string()
        {
            var input = @"";

            var output = RFC2047.Encode("");

            Assert.Equal("", output);
        }
Esempio n. 2
0
        public void Should_add_separators_so_lines_do_not_exceed_75_characters()
        {
            var inputText         = "This is some very long text. It should be split so no line exceeds 75 characters and should have the separator in between";
            var inputCharacterSet = "iso-8859-1";
            var encodingType      = RFC2047.ContentEncoding.Base64;

            var result = RFC2047.Encode(inputText, encodingType, inputCharacterSet).Split(new[] { "\r\n " }, StringSplitOptions.RemoveEmptyEntries);

            Assert.False(result.Where(l => l.Length > 75).Any());
        }
Esempio n. 3
0
        public void Should_encode_to_q_encoding()
        {
            var inputText         = "¡Hola, señor!";
            var inputCharacterSet = "iso-8859-1";
            var encodingType      = RFC2047.ContentEncoding.QEncoding;

            var result = RFC2047.Encode(inputText, encodingType, inputCharacterSet);

            Assert.Equal("=?iso-8859-1?Q?=A1Hola=2C_se=F1or!?=", result);
        }
Esempio n. 4
0
        public void Should_encode_to_b_encoding()
        {
            var inputText         = "Some test text";
            var inputCharacterSet = "iso-8859-1";
            var encodingType      = RFC2047.ContentEncoding.Base64;

            var result = RFC2047.Encode(inputText, encodingType, inputCharacterSet);

            Assert.Equal("=?iso-8859-1?B?U29tZSB0ZXN0IHRleHQ=?=", result);
        }
Esempio n. 5
0
        public void Should_decode_q_encoded_text_back_to_original_text()
        {
            var inputText         = "¡Hola, señor!";
            var inputCharacterSet = "iso-8859-1";
            var encodingType      = RFC2047.ContentEncoding.QEncoding;
            var encoded           = RFC2047.Encode(inputText, encodingType, inputCharacterSet);

            var result = RFC2047.Decode(encoded);

            Assert.Equal(inputText, result);
        }
Esempio n. 6
0
 public void Should_throw_when_encoding_with_invalid_character_set()
 {
     Assert.Throws(typeof(ArgumentException), () => RFC2047.Encode("test", RFC2047.ContentEncoding.QEncoding, "fake"));
 }
Esempio n. 7
0
 public void Should_throw_when_encoding_with_unknown_content_encoding()
 {
     Assert.Throws(typeof(ArgumentException), () => RFC2047.Encode("test", RFC2047.ContentEncoding.Unknown));
 }