Example #1
0
        public void String_Returning_FromBase64_Detects_Encoding_From_ByteMark_When_Null_Encoding_Is_Given(string enc)
        {
            using (var buff = new MemoryStream())
            {
                var encIns  = Encoding.GetEncoding(enc.TrimSafeOrDefault("utf-8"));
                var dataArr = encIns.GetPreamble();
                buff.Write(dataArr, 0, dataArr.Length);
                dataArr = encIns.GetBytes(TestValues.BigString);
                buff.Write(dataArr, 0, dataArr.Length);

                var extB64    = new ArraySegment <byte>(buff.GetBuffer(), 0, (int)buff.Length).ToBase64();
                var resultStr = extB64.FromBase64(null);
                Assert.True(TestValues.BigString.Equals(resultStr));
            }
        }