Beispiel #1
0
        public void AddApplicationManager_OverridesDefaultManager()
        {
            // Arrange
            var services = new ServiceCollection();

            services.AddOptions();

            var builder = new OpenIddictBuilder(services);

            builder.ApplicationType = typeof(object);

            var type = new Mock <OpenIddictApplicationManager <object> >(
                Mock.Of <IServiceProvider>(),
                Mock.Of <IOpenIddictApplicationStore <object> >(),
                Mock.Of <ILogger <OpenIddictApplicationManager <object> > >()).Object.GetType();

            // Act
            builder.AddApplicationManager(type);

            var provider = services.BuildServiceProvider();
            var manager  = provider.GetRequiredService <OpenIddictApplicationManager <object> >();

            // Assert
            Assert.IsType(type, manager);
        }
        public void AddApplicationManager_ThrowsAnExceptionForInvalidManager()
        {
            // Arrange
            var services = new ServiceCollection();

            services.AddOptions();

            var builder = new OpenIddictBuilder(services);

            builder.ApplicationType = typeof(object);

            // Act and assert
            var exception = Assert.Throws <InvalidOperationException>(() => builder.AddApplicationManager(typeof(object)));

            Assert.Equal("The specified type is invalid.", exception.Message);
        }