public void Configure_ThrowsAnExceptionForNullOptions()
        {
            // Arrange
            var configuration = new OpenIddictServerConfiguration(
                Mock.Of <IDistributedCache>(),
                Mock.Of <IDataProtectionProvider>());

            // Act and assert
            var exception = Assert.Throws <ArgumentNullException>(() => configuration.Configure(null));

            Assert.Equal("options", exception.ParamName);
        }
        public void Configure_ThrowsAnExceptionWhenSchemeIsAlreadyRegisteredWithDifferentHandlerType()
        {
            // Arrange
            var options = new AuthenticationOptions();

            options.AddScheme(OpenIddictServerDefaults.AuthenticationScheme, builder =>
            {
                builder.HandlerType = typeof(OpenIdConnectServerHandler);
            });

            var configuration = new OpenIddictServerConfiguration(
                Mock.Of <IDistributedCache>(),
                Mock.Of <IDataProtectionProvider>());

            // Act and assert
            var exception = Assert.Throws <InvalidOperationException>(() => configuration.Configure(options));

            Assert.Equal(new StringBuilder()
                         .AppendLine("The OpenIddict server handler cannot be registered as an authentication scheme.")
                         .AppendLine("This may indicate that an instance of the OpenID Connect server was registered.")
                         .Append("Make sure that 'services.AddAuthentication().AddOpenIdConnectServer()' is not used.")
                         .ToString(), exception.Message);
        }