// A simple test program for the Base64Coder class. using Base64Coder = source_code_biz.Base64Coder; using Console = System.Console; using Exception = System.Exception; namespace source_code_biz { internal class TestBase64Coder { public static int Main (string[] args) { test1(); Console.WriteLine("OK"); return 0; } private static void test1() { check("Aladdin:open sesame", "QWxhZGRpbjpvcGVuIHNlc2FtZQ=="); // example from RFC 2617 check("", ""); check("1", "MQ=="); check("22", "MjI="); check("333", "MzMz"); check("4444", "NDQ0NA=="); check("55555", "NTU1NTU="); check("abc:def", "YWJjOmRlZg=="); } private static void check (string plainText, string base64Text) { string s1 = Base64Coder.EncodeString(plainText); string s2 = Base64Coder.DecodeString(base64Text); if (s1 != base64Text || s2 != plainText) { throw new Exception("Check failed for \"" + plainText + "\" / \"" + base64Text + "\"."); }} } // end class TestBase64Coder } // end namespace