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

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

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

            Assert.Equal(SR.GetResourceString(SR.ID0260), exception.Message);
        }
Пример #2
0
    public void Get_ReturnsCustomStoreCorrespondingToTheSpecifiedTypeWhenAvailable()
    {
        // Arrange
        var services = new ServiceCollection();

        services.AddSingleton(Mock.Of <IOpenIddictTokenStore <CustomToken> >());

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

        // Act and assert
        Assert.NotNull(resolver.Get <CustomToken>());
    }
Пример #3
0
        public void Get_ThrowsAnExceptionForInvalidEntityType()
        {
            // Arrange
            var services = new ServiceCollection();

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

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

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