public void Get_ReturnsCustomStoreCorrespondingToTheSpecifiedTypeWhenAvailable()
        {
            // Arrange
            var services = new ServiceCollection();

            services.AddSingleton(Mock.Of <IOpenIddictScopeStore <CustomScope> >());

            var provider = services.BuildServiceProvider();
            var resolver = new OpenIddictMongoDbScopeStoreResolver(provider);

            // Act and assert
            Assert.NotNull(resolver.Get <CustomScope>());
        }
        public void Get_ThrowsAnExceptionForInvalidEntityType()
        {
            // Arrange
            var services = new ServiceCollection();

            var provider = services.BuildServiceProvider();
            var resolver = new OpenIddictMongoDbScopeStoreResolver(provider);

            // Act and assert
            var exception = Assert.Throws <InvalidOperationException>(() => resolver.Get <CustomScope>());

            Assert.Equal(SR.GetResourceString(SR.ID1258), exception.Message);
        }
        public void Get_ThrowsAnExceptionForInvalidEntityType()
        {
            // Arrange
            var services = new ServiceCollection();

            var provider = services.BuildServiceProvider();
            var resolver = new OpenIddictMongoDbScopeStoreResolver(provider);

            // Act and assert
            var exception = Assert.Throws <InvalidOperationException>(() => resolver.Get <CustomScope>());

            Assert.Equal(new StringBuilder()
                         .AppendLine("The specified scope type is not compatible with the MongoDB stores.")
                         .Append("When enabling the MongoDB stores, make sure you use the built-in ")
                         .Append("'OpenIddictMongoDbScope' entity or a custom entity that inherits ")
                         .Append("from the 'OpenIddictMongoDbScope' entity.")
                         .ToString(), exception.Message);
        }