Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void encodingShouldContainOnlyBase64EncodingChars()
        public virtual void EncodingShouldContainOnlyBase64EncodingChars()
        {
            string[] array   = new string[] { "This string is long enough for BASE64 to emit a line break, making the encoding platform dependant.", "Something else to trigger padding." };
            string   encoded = ArrayEncoder.Encode(Values.of(array));

            int  separators = 0;
            bool padding    = false;

            for (int i = 0; i < encoded.Length; i++)
            {
                char character = encoded[i];
                if (character == ARRAY_ENTRY_SEPARATOR)
                {
                    padding = false;
                    separators++;
                }
                else if (padding)
                {
                    assertEquals(PADDING, character);
                }
                else if (character == PADDING)
                {
                    padding = true;
                }
                else
                {
                    assertTrue("Char " + character + " at position " + i + " is not a valid Base64 encoded char", ArrayUtil.contains(_base64chars, character));
                }
            }
            assertEquals(array.Length, separators);
        }
Пример #2
0
 private void AssertEncoding(string expected, object toEncode)
 {
     assertEquals(expected, ArrayEncoder.Encode(Values.of(toEncode)));
 }