public void TestDeserializerValidMultipleIdentities() { var json = File.ReadAllText("./TestAssets/UserAssignedIdentity/UserAssignedValidMultipleIdentities.json"); JsonDocument document = JsonDocument.Parse(json); UserAssignedIdentity[] identities = new UserAssignedIdentity[2]; var properties = document.RootElement.EnumerateObject().First().Value; int count = 0; foreach (var property in properties.EnumerateObject()) { if (property.NameEquals("userAssignedIdentities")) { foreach (var keyValuePair in property.Value.EnumerateObject()) { identities[count] = UserAssignedIdentity.Deserialize(keyValuePair.Value); count++; } } } Assert.IsTrue("3beb288c-c3f9-4300-896f-02fbf175b6be".Equals(identities[0].ClientId.ToString())); Assert.IsTrue("d0416856-d6cf-466d-8d64-ddc8d7782096".Equals(identities[0].PrincipalId.ToString())); Assert.IsTrue("fbb39377-ff46-4a82-8c47-42d573180482".Equals(identities[1].ClientId.ToString())); Assert.IsTrue("6d63ce43-c3ac-4b03-933d-4bc31eae50b2".Equals(identities[1].PrincipalId.ToString())); }
public void TestDeserializerBothValuesNull() { var identityJsonProperty = DeserializerHelper("UserAssignedBothValuesNull.json"); var back = UserAssignedIdentity.Deserialize(identityJsonProperty); Assert.IsNull(back); }
public void TestDeserializerValid() { var identityJsonProperty = DeserializerHelper("UserAssignedValid.json"); UserAssignedIdentity back = UserAssignedIdentity.Deserialize(identityJsonProperty); Assert.IsTrue("3beb288c-c3f9-4300-896f-02fbf175b6be".Equals(back.ClientId.ToString())); Assert.IsTrue("d0416856-d6cf-466d-8d64-ddc8d7782096".Equals(back.PrincipalId.ToString())); }
public void TestDeserializerInvalidMultipleIdentities() { var json = File.ReadAllText("./TestAssets/UserAssignedIdentity/UserAssignedInvalidMultipleIdentities.json"); JsonDocument document = JsonDocument.Parse(json); var properties = document.RootElement.EnumerateObject().First().Value; foreach (var property in properties.EnumerateObject()) { if (property.NameEquals("userAssignedIdentities")) { foreach (var keyValuePair in property.Value.EnumerateObject()) { Assert.Throws <InvalidOperationException>(delegate { UserAssignedIdentity.Deserialize(keyValuePair.Value); }); } } } }
public void TestDeserializerDefaultJson() { JsonElement invalid = default(JsonElement); Assert.Throws <ArgumentException>(delegate { UserAssignedIdentity.Deserialize(invalid); }); }
public void TestDeserializerClientIdInvalid() { var identityJsonProperty = DeserializerHelper("UserAssignedInvalid.json"); Assert.Throws <InvalidOperationException>(delegate { UserAssignedIdentity.Deserialize(identityJsonProperty); }); }
public void TestDeserializerPrincipalIdValueNull() { var identityJsonProperty = DeserializerHelper("UserAssignedOneOtherValueNull.json"); Assert.Throws <InvalidOperationException>(delegate { UserAssignedIdentity.Deserialize(identityJsonProperty); }); }
public void TestDeserializerOneEmptyString() { var identityJsonProperty = DeserializerHelper("UserAssignedOneEmptyString.json"); Assert.Throws <FormatException>(delegate { UserAssignedIdentity.Deserialize(identityJsonProperty); }); }