public void OneExtraCharacter_ThrowsFormatException() { using (var inputReader = new StringReader("Zm9vY")) { using (var decodedStream = new Base64DecodingStream(inputReader)) { Assert.Throws <FormatException>(() => Console.WriteLine(decodedStream.AsString(Encoding.UTF8))); } } }
public void MissingPadChars(string input, string expectedOutput) { using (var inputReader = new StringReader(input)) { using (var decodedStream = new Base64DecodingStream(inputReader)) { Assert.AreEqual(expectedOutput, decodedStream.AsString(Encoding.UTF8)); } } }
public void LongBase64String_ShortBufferSize() { string filename = @"C:\Users\epohl\Dropbox\projects\Base64Streaming\Base64Streaming.Test\base64.txt"; using (var inputStream = File.Open(filename, FileMode.Open, FileAccess.Read)) { var inputReader = new StreamReader(inputStream); using (var decodedStream = new Base64DecodingStream(inputReader)) { Console.WriteLine(decodedStream.AsString(Encoding.UTF8)); } } }
public void Test1(string expected) { byte[] bytes = Encoding.UTF8.GetBytes(expected); string base64 = Convert.ToBase64String(bytes); Console.WriteLine("{0} => {1}", expected, base64); var textReader = new StringReader(base64); using (var stream = new Base64DecodingStream(textReader)) { Assert.AreEqual(expected, stream.AsString(Encoding.UTF8)); } }