44using System ;
55using System . IO ;
66using System . Linq ;
7+ using System . Threading . Tasks ;
78using Microsoft . Framework . Caching . Distributed ;
89using Microsoft . Framework . DependencyInjection ;
910using Xunit ;
11+
1012namespace Microsoft . Framework . Caching . Redis
1113{
1214 public class CacheServiceExtensionsTests
1315 {
14-
15-
1616 [ Fact ]
17- public void AddRedisCache_RegistersDistributedCacheAsTransient ( )
17+ public void AddRedisCache_RegistersDistributedCacheAsSingleton ( )
1818 {
1919 // Arrange
2020 var services = new ServiceCollection ( ) ;
@@ -26,7 +26,7 @@ public void AddRedisCache_RegistersDistributedCacheAsTransient()
2626 var distributedCache = services . FirstOrDefault ( desc => desc . ServiceType == typeof ( IDistributedCache ) ) ;
2727
2828 Assert . NotNull ( distributedCache ) ;
29- Assert . Equal ( ServiceLifetime . Transient , distributedCache . Lifetime ) ;
29+ Assert . Equal ( ServiceLifetime . Singleton , distributedCache . Lifetime ) ;
3030 }
3131
3232 [ Fact ]
@@ -37,7 +37,7 @@ public void AddRedisCache_DoesNotReplaceUserRegisteredServices()
3737 services . AddScoped < IDistributedCache , TestDistributedCache > ( ) ;
3838
3939 // Act
40- services . AddCaching ( ) ;
40+ services . AddRedisCache ( ) ;
4141
4242 // Assert
4343 var serviceProvider = services . BuildServiceProvider ( ) ;
@@ -49,25 +49,54 @@ public void AddRedisCache_DoesNotReplaceUserRegisteredServices()
4949 Assert . IsType < TestDistributedCache > ( serviceProvider . GetRequiredService < IDistributedCache > ( ) ) ;
5050 }
5151
52-
5352 private class TestDistributedCache : IDistributedCache
5453 {
5554 public void Connect ( )
5655 {
5756 throw new NotImplementedException ( ) ;
5857 }
5958
59+ public Task ConnectAsync ( )
60+ {
61+ throw new NotImplementedException ( ) ;
62+ }
63+
64+ public byte [ ] Get ( string key )
65+ {
66+ throw new NotImplementedException ( ) ;
67+ }
68+
69+ public Task < byte [ ] > GetAsync ( string key )
70+ {
71+ throw new NotImplementedException ( ) ;
72+ }
73+
6074 public void Refresh ( string key )
6175 {
6276 throw new NotImplementedException ( ) ;
6377 }
6478
79+ public Task RefreshAsync ( string key )
80+ {
81+ throw new NotImplementedException ( ) ;
82+ }
83+
6584 public void Remove ( string key )
6685 {
6786 throw new NotImplementedException ( ) ;
6887 }
6988
70- public Stream Set ( string key , object state , Action < ICacheContext > create )
89+ public Task RemoveAsync ( string key )
90+ {
91+ throw new NotImplementedException ( ) ;
92+ }
93+
94+ public void Set ( string key , byte [ ] value , DistributedCacheEntryOptions options )
95+ {
96+ throw new NotImplementedException ( ) ;
97+ }
98+
99+ public Task SetAsync ( string key , byte [ ] value , DistributedCacheEntryOptions options )
71100 {
72101 throw new NotImplementedException ( ) ;
73102 }
0 commit comments