Skip to content

Commit 3cbe7a7

Browse files
Add missing patch coverage
Add coverage highlighted as missing from the patch.
1 parent dc50439 commit 3cbe7a7

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

test/Polly.Specs/Bulkhead/BulkheadTResultAsyncSpecs.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ public void Should_throw_when_onBulkheadRejected_is_null()
7272
.ParamName.ShouldBe("onBulkheadRejectedAsync");
7373
}
7474

75+
[Fact]
76+
public void Should_not_throw_when_arguments_valid()
77+
{
78+
Action policy = () => Policy.BulkheadAsync<int>(1);
79+
80+
Should.NotThrow(policy);
81+
}
82+
7583
#endregion
7684

7785
#region onBulkheadRejected delegate

test/Polly.Specs/Caching/CacheSpecs.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)