public void TestDecodeEmpty() { var encoded = ""; var result = KvpParser.Decode(encoded); Assert.AreEqual(0, result.Count); }
public static Dictionary <string, string> DecryptProfile(byte[] encrypted) { var decrypted = AesEcb.Decrypt(Key, encrypted); var encoded = PaddingUtil.RemovePad(decrypted); var decoded = KvpParser.Decode(System.Text.Encoding.ASCII.GetString(encoded)); return(decoded); }
public void TestDecodeSingle() { var encoded = "key=val"; var result = KvpParser.Decode(encoded); Assert.AreEqual(1, result.Count); Assert.AreEqual(result["key"], "val"); }
public void TestEncodeEmpty() { var obj = new Dictionary <string, string>(); var encoded = KvpParser.Encode(obj); Assert.AreEqual(string.Empty, encoded); }
public void TestDecodeEmptyValue() { var encoded = "a=&b="; var result = KvpParser.Decode(encoded); Assert.AreEqual(2, result.Count); Assert.AreEqual(string.Empty, result["a"]); Assert.AreEqual(string.Empty, result["b"]); }
public void TestDecodeMultiple() { var encoded = "key1=val1&key2=val2&key3=val3"; var result = KvpParser.Decode(encoded); Assert.AreEqual(3, result.Count); Assert.AreEqual(result["key1"], "val1"); Assert.AreEqual(result["key2"], "val2"); Assert.AreEqual(result["key3"], "val3"); }
public static string ProfileFor(string email) { var profile = new Dictionary <string, string> { { "email", email }, { "uid", "10" }, { "role", "user" } }; return(KvpParser.Encode(profile)); }
public void TestEncodeSingle() { var obj = new Dictionary <string, string> { { "key", "value" } }; var encoded = KvpParser.Encode(obj); Assert.AreEqual("key=value", encoded); }
public void TestEncodeRemoveInvalidChars() { var obj = new Dictionary <string, string> { { "key1=", "=val1" }, { "key2&", "val2&" } }; var encoded = KvpParser.Encode(obj); Assert.AreEqual("key1=val1&key2=val2", encoded); }
public void TestEncodeMultiple() { var obj = new Dictionary <string, string> { { "key1", "val1" }, { "key2", "val2" }, { "key3", "val3" } }; var encoded = KvpParser.Encode(obj); Assert.AreEqual("key1=val1&key2=val2&key3=val3", encoded); }
public void TestDecodeNull() { KvpParser.Decode(null); }
public void TestDecodeInvalidFormatWhitespaceKey() { var encoded = " ="; KvpParser.Decode(encoded); }
public void TestDecodeInvalidFormatEmptyKey() { var encoded = "="; KvpParser.Decode(encoded); }
public void TestEncodeNull() { KvpParser.Encode(null); }