diff --git a/src/Xamarin.Auth/AssemblyInfo.cs b/src/Xamarin.Auth/AssemblyInfo.cs index 463a3d346..c5aa500f4 100644 --- a/src/Xamarin.Auth/AssemblyInfo.cs +++ b/src/Xamarin.Auth/AssemblyInfo.cs @@ -40,3 +40,4 @@ //[assembly: AssemblyDelaySign(false)] //[assembly: AssemblyKeyFile("")] +[assembly: InternalsVisibleTo ("XamarinAuthiOSTest")] \ No newline at end of file diff --git a/src/Xamarin.Auth/WebEx.cs b/src/Xamarin.Auth/WebEx.cs index be053a3d7..ccf152cef 100644 --- a/src/Xamarin.Auth/WebEx.cs +++ b/src/Xamarin.Auth/WebEx.cs @@ -98,7 +98,10 @@ public static Dictionary JsonDecode (string encodedString) foreach (var kv in json) { var v = kv.Value as JsonValue; if (v != null) { - inputs [kv.Key] = (string)v; + if (v.JsonType != JsonType.String) + inputs[kv.Key] = v.ToString(); + else + inputs[kv.Key] = (string)v; } } diff --git a/tests/Xamarin.Auth.iOS.Test/WebExTests.cs b/tests/Xamarin.Auth.iOS.Test/WebExTests.cs new file mode 100644 index 000000000..256395a02 --- /dev/null +++ b/tests/Xamarin.Auth.iOS.Test/WebExTests.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NUnit.Framework; +using Xamarin.Utilities; + +namespace Xamarin.Auth.Test +{ + [TestFixture] + public class WebExTests + { + [TestCase ("{\"string\": \"value\"}","string", "value")] + [TestCase ("{\"int\": 5000}", "int", "5000")] + [TestCase ("{\"bool\": true }", "bool", "true")] + public void JsonDecode (string json, string arg, string value) + { + var dict = WebEx.JsonDecode (json); + string v; + Assert.That (dict.TryGetValue (arg, out v), Is.True, "Dictionary did not contain argument '" + arg + "'"); + Assert.That (v, Is.EqualTo (value)); + } + } +} diff --git a/tests/Xamarin.Auth.iOS.Test/Xamarin.Auth.iOS.Test.csproj b/tests/Xamarin.Auth.iOS.Test/Xamarin.Auth.iOS.Test.csproj index e128a6f09..cb3e12944 100644 --- a/tests/Xamarin.Auth.iOS.Test/Xamarin.Auth.iOS.Test.csproj +++ b/tests/Xamarin.Auth.iOS.Test/Xamarin.Auth.iOS.Test.csproj @@ -92,6 +92,7 @@ +