RedisDataProtectionBuilderExtensionsTest.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using Microsoft.AspNetCore.DataProtection.KeyManagement;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Options;
  6. using Moq;
  7. using StackExchange.Redis;
  8. using Xunit;
  9. namespace Microsoft.AspNetCore.DataProtection.Redis
  10. {
  11. public class RedisDataProtectionBuilderExtensionsTest
  12. {
  13. [Fact]
  14. public void PersistKeysToRedis_UsesRedisXmlRepository()
  15. {
  16. // Arrange
  17. var connection = Mock.Of<IConnectionMultiplexer>();
  18. var serviceCollection = new ServiceCollection();
  19. var builder = serviceCollection.AddDataProtection();
  20. // Act
  21. builder.PersistKeysToRedis(connection);
  22. var services = serviceCollection.BuildServiceProvider();
  23. // Assert
  24. var options = services.GetRequiredService<IOptions<KeyManagementOptions>>();
  25. Assert.IsType<RedisXmlRepository>(options.Value.XmlRepository);
  26. }
  27. }
  28. }