Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CA1806 #1963

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ public class AbsoluteTtlSpecs : IDisposable
[Fact]
public void Should_be_able_to_configure_for_near_future_time()
{
Action configure = () => new AbsoluteTtl(DateTimeOffset.UtcNow.Date.AddDays(1));
gintsk marked this conversation as resolved.
Show resolved Hide resolved
Action configure = () => _ = new AbsoluteTtl(DateTimeOffset.UtcNow.Date.AddDays(1));

configure.Should().NotThrow();
}

[Fact]
public void Should_be_able_to_configure_for_far_future()
{
Action configure = () => new AbsoluteTtl(DateTimeOffset.MaxValue);
Action configure = () => _ = new AbsoluteTtl(DateTimeOffset.MaxValue);

configure.Should().NotThrow();
}

[Fact]
public void Should_be_able_to_configure_for_past()
{
Action configure = () => new AbsoluteTtl(DateTimeOffset.MinValue);
Action configure = () => _ = new AbsoluteTtl(DateTimeOffset.MinValue);

configure.Should().NotThrow();
}
Expand Down
6 changes: 3 additions & 3 deletions test/Polly.Specs/Caching/RelativeTtlSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ public class RelativeTtlSpecs
[Fact]
public void Should_throw_when_timespan_is_less_than_zero()
{
Action configure = () => new RelativeTtl(TimeSpan.FromMilliseconds(-1));
Action configure = () => _ = new RelativeTtl(TimeSpan.FromMilliseconds(-1));

configure.Should().Throw<ArgumentOutOfRangeException>().And.ParamName.Should().Be("ttl");
}

[Fact]
public void Should_not_throw_when_timespan_is_zero()
{
Action configure = () => new RelativeTtl(TimeSpan.Zero);
Action configure = () => _ = new RelativeTtl(TimeSpan.Zero);

configure.Should().NotThrow();
}

[Fact]
public void Should_allow_timespan_max_value()
{
Action configure = () => new RelativeTtl(TimeSpan.MaxValue);
Action configure = () => _ = new RelativeTtl(TimeSpan.MaxValue);

configure.Should().NotThrow();
}
Expand Down
8 changes: 4 additions & 4 deletions test/Polly.Specs/Caching/ResultTtlSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ public class ResultTtlSpecs
[Fact]
public void Should_throw_when_func_is_null()
{
Action configure = () => new ResultTtl<object>((Func<object?, Ttl>)null!);
Action configure = () => _ = new ResultTtl<object>((Func<object?, Ttl>)null!);

configure.Should().Throw<ArgumentNullException>().And.ParamName.Should().Be("ttlFunc");
}

[Fact]
public void Should_throw_when_func_is_null_using_context()
{
Action configure = () => new ResultTtl<object>((Func<Context, object?, Ttl>)null!);
Action configure = () => _ = new ResultTtl<object>((Func<Context, object?, Ttl>)null!);

configure.Should().Throw<ArgumentNullException>().And.ParamName.Should().Be("ttlFunc");
}

[Fact]
public void Should_not_throw_when_func_is_set()
{
Action configure = () => new ResultTtl<object>(_ => new Ttl());
Action configure = () => _ = new ResultTtl<object>(_ => new Ttl());

configure.Should().NotThrow();
}

[Fact]
public void Should_not_throw_when_func_is_set_using_context()
{
Action configure = () => new ResultTtl<object>((_, _) => new Ttl());
Action configure = () => _ = new ResultTtl<object>((_, _) => new Ttl());

configure.Should().NotThrow();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void Single_generic_constructor_should_throw_on_no_wrapped_cache_provider
serialize: o => new StubSerialized(o),
deserialize: s => s?.Original ?? default);

Action configure = () => new AsyncSerializingCacheProvider<StubSerialized>(null!, stubObjectSerializer);
Action configure = () => _ = new AsyncSerializingCacheProvider<StubSerialized>(null!, stubObjectSerializer);

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("wrappedCacheProvider");
Expand All @@ -20,7 +20,7 @@ public void Single_generic_constructor_should_throw_on_no_wrapped_cache_provider
[Fact]
public void Single_generic_constructor_should_throw_on_no_serializer()
{
Action configure = () => new AsyncSerializingCacheProvider<object>(new StubCacheProvider().AsyncFor<object>(), null!);
Action configure = () => _ = new AsyncSerializingCacheProvider<object>(new StubCacheProvider().AsyncFor<object>(), null!);

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("serializer");
Expand Down Expand Up @@ -221,7 +221,7 @@ public void Double_generic_constructor_should_throw_on_no_wrapped_cache_provider
serialize: o => new StubSerialized<ResultPrimitive>(o),
deserialize: s => s?.Original ?? default);

Action configure = () => new AsyncSerializingCacheProvider<ResultPrimitive, StubSerialized<ResultPrimitive>>(null!, stubTResultSerializer);
Action configure = () => _ = new AsyncSerializingCacheProvider<ResultPrimitive, StubSerialized<ResultPrimitive>>(null!, stubTResultSerializer);

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("wrappedCacheProvider");
Expand All @@ -230,7 +230,7 @@ public void Double_generic_constructor_should_throw_on_no_wrapped_cache_provider
[Fact]
public void Double_generic_constructor_should_throw_on_no_serializer()
{
Action configure = () => new AsyncSerializingCacheProvider<object, object>(new StubCacheProvider().AsyncFor<object>(), null!);
Action configure = () => _ = new AsyncSerializingCacheProvider<object, object>(new StubCacheProvider().AsyncFor<object>(), null!);

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("serializer");
Expand Down
8 changes: 4 additions & 4 deletions test/Polly.Specs/Caching/SerializingCacheProviderSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void Single_generic_constructor_should_throw_on_no_wrapped_cache_provider
serialize: o => new StubSerialized(o),
deserialize: s => s?.Original ?? default);

Action configure = () => new SerializingCacheProvider<StubSerialized>(null!, stubObjectSerializer);
Action configure = () => _ = new SerializingCacheProvider<StubSerialized>(null!, stubObjectSerializer);

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("wrappedCacheProvider");
Expand All @@ -20,7 +20,7 @@ public void Single_generic_constructor_should_throw_on_no_wrapped_cache_provider
[Fact]
public void Single_generic_constructor_should_throw_on_no_serializer()
{
Action configure = () => new SerializingCacheProvider<object>(new StubCacheProvider().For<object>(), null!);
Action configure = () => _ = new SerializingCacheProvider<object>(new StubCacheProvider().For<object>(), null!);

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("serializer");
Expand Down Expand Up @@ -221,7 +221,7 @@ public void Double_generic_constructor_should_throw_on_no_wrapped_cache_provider
serialize: o => new StubSerialized<ResultPrimitive>(o),
deserialize: s => s?.Original ?? default);

Action configure = () => new SerializingCacheProvider<ResultPrimitive, StubSerialized<ResultPrimitive>>(null!, stubTResultSerializer);
Action configure = () => _ = new SerializingCacheProvider<ResultPrimitive, StubSerialized<ResultPrimitive>>(null!, stubTResultSerializer);

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("wrappedCacheProvider");
Expand All @@ -230,7 +230,7 @@ public void Double_generic_constructor_should_throw_on_no_wrapped_cache_provider
[Fact]
public void Double_generic_constructor_should_throw_on_no_serializer()
{
Action configure = () => new SerializingCacheProvider<object, object>(new StubCacheProvider().For<object>(), null!);
Action configure = () => _ = new SerializingCacheProvider<object, object>(new StubCacheProvider().For<object>(), null!);

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("serializer");
Expand Down
6 changes: 3 additions & 3 deletions test/Polly.Specs/Caching/SlidingTtlSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ public class SlidingTtlSpecs
[Fact]
public void Should_throw_when_timespan_is_less_than_zero()
{
Action configure = () => new SlidingTtl(TimeSpan.FromMilliseconds(-1));
Action configure = () => _ = new SlidingTtl(TimeSpan.FromMilliseconds(-1));

configure.Should().Throw<ArgumentOutOfRangeException>().And.ParamName.Should().Be("slidingTtl");
}

[Fact]
public void Should_not_throw_when_timespan_is_zero()
{
Action configure = () => new SlidingTtl(TimeSpan.Zero);
Action configure = () => _ = new SlidingTtl(TimeSpan.Zero);

configure.Should().NotThrow();
}

[Fact]
public void Should_allow_timespan_max_value()
{
Action configure = () => new SlidingTtl(TimeSpan.MaxValue);
Action configure = () => _ = new SlidingTtl(TimeSpan.MaxValue);

configure.Should().NotThrow();
}
Expand Down
2 changes: 1 addition & 1 deletion test/Polly.Specs/Polly.Specs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Threshold>75,60,70</Threshold>
<Include>[Polly]*</Include>
<IncludePollyUsings>true</IncludePollyUsings>
<NoWarn>$(NoWarn);S103;S104;IDE0011;SA1600;SA1204;CA2008;CA1806;CA2201;</NoWarn>
<NoWarn>$(NoWarn);S103;S104;IDE0011;SA1600;SA1204;CA2008;CA2201;</NoWarn>
<NoWarn>$(NoWarn);S3878;CA1030;S3717;SA1129;S1402;SA1649;SA1402;CA1031</NoWarn>
<NoWarn>$(NoWarn);S2184;</NoWarn>
</PropertyGroup>
Expand Down