public async Task FromFile()
        {
            var context = new CompareContext();
            var configuration = await GetConfigurationAsync(OpenIdConfigData.JsonFile, ExpectedException.NoExceptionExpected, OpenIdConfigData.FullyPopulatedWithKeys, context);

            // jwt_uri points to bad formated JSON
            configuration = await GetConfigurationAsync(OpenIdConfigData.JsonWebKeySetBadUriFile, ExpectedException.IOException(inner: typeof(FileNotFoundException)), null, context);

            // reading form a file that does not exist
            configuration = await GetConfigurationAsync("FileDoesNotExist.json", ExpectedException.IOException(inner: typeof(FileNotFoundException)), null, context);
            TestUtilities.AssertFailIfErrors(context);
        }
        public async Task FromJson()
        {
            var context       = new CompareContext();
            var configuration = await GetConfigurationFromMixedAsync(OpenIdConfigData.OpenIdConnectMetadataPingString, expectedException : ExpectedException.NoExceptionExpected);

            configuration = await GetConfigurationFromMixedAsync(OpenIdConfigData.OpenIdConnectMetadataPingLabsJWKSString, expectedException : ExpectedException.NoExceptionExpected);

            IdentityComparer.AreEqual(configuration, OpenIdConfigData.PingLabs, context);

            configuration = await GetConfigurationFromMixedAsync(OpenIdConfigData.JsonAllValues, expectedException : ExpectedException.NoExceptionExpected);

            IdentityComparer.AreEqual(configuration, OpenIdConfigData.FullyPopulatedWithKeys, context);

            // jwt_uri is not reachable
            await GetConfigurationFromTextAsync(OpenIdConfigData.OpenIdConnectMetadataBadUriKeysString, string.Empty, expectedException : ExpectedException.IOException());

            // stream is not well formated
            await GetConfigurationFromTextAsync(OpenIdConfigData.OpenIdConnectMetadataBadFormatString, string.Empty, expectedException : new ExpectedException(typeExpected: typeof(Newtonsoft.Json.JsonReaderException)));

            configuration = await GetConfigurationFromMixedAsync(OpenIdConfigData.OpenIdConnectMetadataSingleX509DataString, expectedException : ExpectedException.NoExceptionExpected);

            IdentityComparer.AreEqual(configuration, OpenIdConfigData.SingleX509Data, context);

            // dnx 5.0 throws a different exception
            // 5.0 - Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException
            // 4.5.1 - System.Security.Cryptography.CryptographicException
            // for now turn off checking for inner
            var ee = ExpectedException.InvalidOperationException(inner: typeof(CryptographicException));

            ee.IgnoreInnerException = true;
            await GetConfigurationFromMixedAsync(OpenIdConfigData.OpenIdConnectMetadataBadX509DataString, expectedException : ee);
            await GetConfigurationFromMixedAsync(OpenIdConfigData.OpenIdConnectMetadataBadBase64DataString, expectedException : ExpectedException.InvalidOperationException(inner: typeof(FormatException)));

            TestUtilities.AssertFailIfErrors(context);
        }
        public async Task FromNetwork()
        {
            OpenIdConnectConfiguration configuration = await GetConfigurationFromHttpAsync(OpenIdConfigData.AADCommonUrl, expectedException : ExpectedException.NoExceptionExpected);

            Assert.NotNull(configuration);

            await GetConfigurationFromHttpAsync(string.Empty, expectedException : ExpectedException.ArgumentNullException());
            await GetConfigurationFromHttpAsync(OpenIdConfigData.BadUri, expectedException : ExpectedException.ArgumentException("IDX20108:"));
            await GetConfigurationFromHttpAsync(OpenIdConfigData.HttpsBadUri, expectedException : ExpectedException.IOException(inner: typeof(HttpRequestException)));
        }
        public void GetDocuments()
        {
            FileDocumentRetriever docRetriever = new FileDocumentRetriever();

            GetDocument(null, docRetriever, CancellationToken.None, ExpectedException.ArgumentNullException());
            GetDocument("OpenIdConnectMetadata.json", docRetriever, CancellationToken.None, ExpectedException.IOException("IDX10804:", typeof(FileNotFoundException), "IDX10814:"));
            GetDocument("ValidJson.json", docRetriever, CancellationToken.None, ExpectedException.NoExceptionExpected);
        }