public void EncodedStreamFactory_WhenAskedForEncodedStream_WithUnknown_ShouldThrow()
        {
            var esf    = new EncodedStreamFactory();
            var stream = new MemoryStream();

            Assert.Throws <NotSupportedException>(() => esf.GetEncoder(TransferEncoding.Unknown, stream));
        }
        public void EncodedStreamFactory_WhenAskedForEncodedStreamForHeader_WithBase64_ShouldReturnBase64Stream()
        {
            var esf = new EncodedStreamFactory();
            IEncodableStream test = esf.GetEncoderForHeader(Encoding.UTF8, true, 5);

            Assert.True(test is Base64Stream);
        }
        public void EncodedStreamFactory_WhenAskedForEncodedStream_WithQuotedPrintable_ShouldReturnQuotedPrintableStream()
        {
            var esf               = new EncodedStreamFactory();
            var stream            = new MemoryStream();
            IEncodableStream test = esf.GetEncoder(TransferEncoding.QuotedPrintable, stream);

            Assert.True(test is QuotedPrintableStream, "Factory returned wrong stream");
            Assert.True(test.GetStream() != null, "GetStream was null");
            Assert.True(test.GetStream() is Stream, "GetStream was not a Stream");
        }
        public void EncodedStreamFactory_WhenAskedForEncodedStream_WithBase64_ShouldReturnBase64Stream()
        {
            var              esf    = new EncodedStreamFactory();
            Stream           stream = new MemoryStream();
            IEncodableStream test   = esf.GetEncoder(TransferEncoding.Base64, stream);

            Assert.True(test is Base64Stream);
            Assert.True(test.GetStream() != null);
            Assert.True(test.GetStream() is Stream);
        }
Пример #5
0
        public void EncodedStreamFactory_WhenAskedForEncodedStream_WithBase64_ShouldReturnBase64Stream()
        {
            var esf = new EncodedStreamFactory();
            Stream stream = new MemoryStream();
            IEncodableStream test = esf.GetEncoder(TransferEncoding.Base64, stream);

            Assert.True(test is Base64Stream);
            Assert.True(test.GetStream() != null);
            Assert.True(test.GetStream() is Stream);
        }
Пример #6
0
        public void EncodedStreamFactory_WhenAskedForEncodedStream_WithQuotedPrintable_ShouldReturnQuotedPrintableStream()
        {
            var esf = new EncodedStreamFactory();
            var stream = new MemoryStream();
            IEncodableStream test = esf.GetEncoder(TransferEncoding.QuotedPrintable, stream);

            Assert.True(test is QuotedPrintableStream, "Factory returned wrong stream");
            Assert.True(test.GetStream() != null, "GetStream was null");
            Assert.True(test.GetStream() is Stream, "GetStream was not a Stream");
        }
Пример #7
0
        public void EncodeString_IsSameAsEncodeBytes_IfOneByteCodepointOnLineWrap(bool useBase64Encoding, string value)
        {
            IEncodableStream streamForEncodeString = EncodedStreamFactory.GetEncoderForHeader(Encoding.UTF8, useBase64Encoding, 0);
            IEncodableStream streamForEncodeBytes  = EncodedStreamFactory.GetEncoderForHeader(Encoding.UTF8, useBase64Encoding, 0);

            streamForEncodeString.EncodeString(value, Encoding.UTF8);
            string encodeStringResult = streamForEncodeString.GetEncodedString();

            byte[] bytes = Encoding.UTF8.GetBytes(value);
            streamForEncodeBytes.EncodeBytes(bytes, 0, bytes.Length);
            string encodeBytesResult = streamForEncodeBytes.GetEncodedString();

            Assert.Equal(encodeBytesResult, encodeStringResult);
        }
Пример #8
0
 public void EncodedStreamFactory_WhenAskedForEncodedStreamForHeader_WithBase64_ShouldReturnBase64Stream()
 {
     var esf = new EncodedStreamFactory();
     IEncodableStream test = esf.GetEncoderForHeader(Encoding.UTF8, true, 5);
     Assert.True(test is Base64Stream);
 }
Пример #9
0
 public void EncodedStreamFactory_WhenAskedForEncodedStream_WithUnknown_ShouldThrow()
 {
     var esf = new EncodedStreamFactory();
     var stream = new MemoryStream();
     Assert.Throws<NotSupportedException>(() => esf.GetEncoder(TransferEncoding.Unknown, stream));
 }