예제 #1
0
        public void TestDeserializerDefaultJson()
        {
            JsonElement invalid = default(JsonElement);

            Assert.Throws <ArgumentException>(delegate
                                              { UserAssignedIdentity.DeserializeUserAssignedIdentity(invalid); });
        }
예제 #2
0
        public void TestDeserializerClientIdInvalid()
        {
            var identityJsonProperty = DeserializerHelper("UserAssignedInvalid.json");

            Assert.Throws <InvalidOperationException>(delegate
                                                      { UserAssignedIdentity.DeserializeUserAssignedIdentity(identityJsonProperty); });
        }
예제 #3
0
        public void TestDeserializerValidMultipleIdentities()
        {
            var          json     = GetFileText("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.DeserializeUserAssignedIdentity(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()));
        }
예제 #4
0
        public void TestDeserializerPrincipalIdValueNull()
        {
            var identityJsonProperty = DeserializerHelper("UserAssignedOneOtherValueNull.json");

            Assert.Throws <InvalidOperationException>(delegate
                                                      { UserAssignedIdentity.DeserializeUserAssignedIdentity(identityJsonProperty); });
        }
예제 #5
0
        public void TestDeserializerOneEmptyString()
        {
            var identityJsonProperty = DeserializerHelper("UserAssignedOneEmptyString.json");

            Assert.Throws <FormatException>(delegate
                                            { UserAssignedIdentity.DeserializeUserAssignedIdentity(identityJsonProperty); });
        }
예제 #6
0
        public void TestDeserializerBothValuesNull()
        {
            var identityJsonProperty = DeserializerHelper("UserAssignedBothValuesNull.json");
            var back = UserAssignedIdentity.DeserializeUserAssignedIdentity(identityJsonProperty);

            Assert.IsNull(back);
        }
예제 #7
0
        public void TestDeserializerValidExtraField()
        {
            var identityJsonProperty  = DeserializerHelper("UserAssignedExtraField.json");
            UserAssignedIdentity back = UserAssignedIdentity.DeserializeUserAssignedIdentity(identityJsonProperty);

            Assert.IsTrue("3beb288c-c3f9-4300-896f-02fbf175b6be".Equals(back.ClientId.ToString()));
            Assert.IsTrue("d0416856-d6cf-466d-8d64-ddc8d7782096".Equals(back.PrincipalId.ToString()));
        }
예제 #8
0
        public void TestDeserializerInvalidMultipleIdentities()
        {
            var          json       = GetFileText("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.DeserializeUserAssignedIdentity(keyValuePair.Value); });
                    }
                }
            }
        }