@@ -59,6 +59,54 @@ public void Should_throw_when_action_is_null()
5959 . ParamName . ShouldBe ( "action" ) ;
6060 }
6161
62+ [ Fact ]
63+ public void Should_not_throw_when_arguments_valid ( )
64+ {
65+ ISyncCacheProvider cacheProvider = new StubCacheProvider ( ) ;
66+ var ttl = TimeSpan . MaxValue ;
67+ ITtlStrategy ttlStrategy = new ContextualTtl ( ) ;
68+ ICacheKeyStrategy cacheKeyStrategy = new StubCacheKeyStrategy ( context => context . OperationKey + context [ "id" ] ) ;
69+ Func < Context , string > cacheKeyStrategyFunc = ( _ ) => string . Empty ;
70+ Action < Context , string > onCache = ( _ , _ ) => { } ;
71+ Action < Context , string , Exception > ? onCacheError = ( _ , _ , _ ) => { } ;
72+
73+ Action action = ( ) => Policy . Cache ( cacheProvider , ttl , onCacheError ) ;
74+ Should . NotThrow ( action ) ;
75+
76+ action = ( ) => Policy . Cache ( cacheProvider , ttlStrategy , onCacheError ) ;
77+ Should . NotThrow ( action ) ;
78+
79+ action = ( ) => Policy . Cache ( cacheProvider , ttl , cacheKeyStrategy , onCacheError ) ;
80+ Should . NotThrow ( action ) ;
81+
82+ action = ( ) => Policy . Cache ( cacheProvider , ttlStrategy , cacheKeyStrategy , onCacheError ) ;
83+ Should . NotThrow ( action ) ;
84+
85+ action = ( ) => Policy . Cache ( cacheProvider , ttl , cacheKeyStrategyFunc , onCacheError ) ;
86+ Should . NotThrow ( action ) ;
87+
88+ action = ( ) => Policy . Cache ( cacheProvider , ttlStrategy , cacheKeyStrategyFunc , onCacheError ) ;
89+ Should . NotThrow ( action ) ;
90+
91+ action = ( ) => Policy . Cache ( cacheProvider , ttl , onCache , onCache , onCache , onCacheError , onCacheError ) ;
92+ Should . NotThrow ( action ) ;
93+
94+ action = ( ) => Policy . Cache ( cacheProvider , ttlStrategy , onCache , onCache , onCache , onCacheError , onCacheError ) ;
95+ Should . NotThrow ( action ) ;
96+
97+ action = ( ) => Policy . Cache ( cacheProvider , ttl , cacheKeyStrategy , onCache , onCache , onCache , onCacheError , onCacheError ) ;
98+ Should . NotThrow ( action ) ;
99+
100+ action = ( ) => Policy . Cache ( cacheProvider , ttlStrategy , cacheKeyStrategy , onCache , onCache , onCache , onCacheError , onCacheError ) ;
101+ Should . NotThrow ( action ) ;
102+
103+ action = ( ) => Policy . Cache ( cacheProvider , ttl , cacheKeyStrategyFunc , onCache , onCache , onCache , onCacheError , onCacheError ) ;
104+ Should . NotThrow ( action ) ;
105+
106+ action = ( ) => Policy . Cache ( cacheProvider , ttlStrategy , cacheKeyStrategyFunc , onCache , onCache , onCache , onCacheError , onCacheError ) ;
107+ Should . NotThrow ( action ) ;
108+ }
109+
62110 [ Fact ]
63111 public void Should_throw_when_cache_provider_is_null ( )
64112 {
0 commit comments