Skip to content

Commit 7cb273e

Browse files
authored
Merge branch 'dev' into po/StreamSupport
2 parents b4101b3 + 3c9ce31 commit 7cb273e

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
using Microsoft.Graph.PowerShell.Authentication.Helpers;
7+
8+
using Xunit;
9+
10+
namespace Microsoft.Graph.Authentication.Test.Helpers
11+
{
12+
public class StringUtilTests
13+
{
14+
private const string TestJsonArray = "{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#users\"," + "\"value\": [{\"id\": \"6e7b768e-07e2-4810-8459-485f84f8f204\"},{\"id\": \"87d349ed-44d7-43e1-9a83-5f2406dee5bd\"}]}";
15+
16+
private const string TestJsonObject = "{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#users/$entity\",\"businessPhones\": [\"+1 412 555 0109\"],\"displayName\": \"Megan Bowen\",\"givenName\": \"Megan\",\"jobTitle\": \"Auditor\",\"mail\": \"[email protected]\", \"mobilePhone\": null, \"officeLocation\": \"12/1110\",\"preferredLanguage\": \"en-US\",\"surname\": \"Bowen\",\"userPrincipalName\": \"[email protected]\",\"id\": \"48d31887-5fad-4d73-a9f5-3c356e68a038\"}";
17+
18+
[Theory]
19+
[MemberData(nameof(TestJsonData))]
20+
public void ShouldReturnCaseInsensitiveDictionaries(string jsonString)
21+
{
22+
Exception ex = null;
23+
var converted = jsonString.TryConvertToJson(out var jsonObj, ref ex);
24+
25+
Assert.True(converted);
26+
Assert.IsType<Hashtable>(jsonObj);
27+
var jsonHashTable = (Hashtable)jsonObj;
28+
Assert.Equal(jsonHashTable["Value"], jsonHashTable["value"]);
29+
}
30+
public static IEnumerable<object[]> TestJsonData =>
31+
new List<object[]>
32+
{
33+
new object[] { TestJsonArray},
34+
new object[] { TestJsonObject}
35+
};
36+
}
37+
}

src/Authentication/Authentication/Helpers/StringUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private static ICollection<object> PopulateHashTableFromJArray(JArray list, out
197197
private static Hashtable PopulateHashTableFromJDictionary(JObject entries, out Exception exception)
198198
{
199199
exception = null;
200-
Hashtable result = new Hashtable(entries.Count);
200+
Hashtable result = new Hashtable(entries.Count, StringComparer.OrdinalIgnoreCase);
201201
foreach (var entry in entries)
202202
{
203203
// Case sensitive duplicates should normally not occur since JsonConvert.DeserializeObject

0 commit comments

Comments
 (0)