public void Get_ReturnsCustomStoreCorrespondingToTheSpecifiedTypeWhenAvailable() { // Arrange var services = new ServiceCollection(); services.AddSingleton(Mock.Of <IOpenIddictApplicationStore <CustomApplication> >()); var provider = services.BuildServiceProvider(); var resolver = new OpenIddictMongoDbApplicationStoreResolver(provider); // Act and assert Assert.NotNull(resolver.Get <CustomApplication>()); }
public void Get_ThrowsAnExceptionForInvalidEntityType() { // Arrange var services = new ServiceCollection(); var provider = services.BuildServiceProvider(); var resolver = new OpenIddictMongoDbApplicationStoreResolver(provider); // Act and assert var exception = Assert.Throws <InvalidOperationException>(() => resolver.Get <CustomApplication>()); Assert.Equal(SR.GetResourceString(SR.ID0257), exception.Message); }
public void Get_ThrowsAnExceptionForInvalidEntityType() { // Arrange var services = new ServiceCollection(); var provider = services.BuildServiceProvider(); var resolver = new OpenIddictMongoDbApplicationStoreResolver(provider); // Act and assert var exception = Assert.Throws <InvalidOperationException>(() => resolver.Get <CustomApplication>()); Assert.Equal(new StringBuilder() .AppendLine("The specified application type is not compatible with the MongoDB stores.") .Append("When enabling the MongoDB stores, make sure you use the built-in ") .Append("'OpenIddictMongoDbApplication' entity or a custom entity that inherits ") .Append("from the 'OpenIddictMongoDbApplication' entity.") .ToString(), exception.Message); }