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 1 commit
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
15 changes: 12 additions & 3 deletions test/Polly.Specs/Caching/AbsoluteTtlSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,32 @@ 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 = () =>
{
AbsoluteTtl ttl = 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 = () =>
{
AbsoluteTtl ttl = 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 = () =>
{
AbsoluteTtl ttl = new AbsoluteTtl(DateTimeOffset.MinValue);
};

configure.Should().NotThrow();
}
Expand Down
20 changes: 16 additions & 4 deletions test/Polly.Specs/Caching/SerializingCacheProviderSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ 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 = () =>
{
SerializingCacheProvider<StubSerialized> serializingCacheProvider = new SerializingCacheProvider<StubSerialized>(null!, stubObjectSerializer);
};

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("wrappedCacheProvider");
Expand All @@ -20,7 +23,10 @@ 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 = () =>
{
SerializingCacheProvider<object> serializingCacheProvider = new SerializingCacheProvider<object>(new StubCacheProvider().For<object>(), null!);
};

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("serializer");
Expand Down Expand Up @@ -221,7 +227,10 @@ 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 = () =>
{
var serializingCacheProvider = new SerializingCacheProvider<ResultPrimitive, StubSerialized<ResultPrimitive>>(null!, stubTResultSerializer);
};

configure.Should().Throw<ArgumentNullException>()
.And.ParamName.Should().Be("wrappedCacheProvider");
Expand All @@ -230,7 +239,10 @@ 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 = () =>
{
var serializingCacheProvider = new SerializingCacheProvider<object, object>(new StubCacheProvider().For<object>(), null!);
};

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

configure.Should().NotThrow();
}

[Fact]
public void Should_allow_timespan_max_value()
{
Action configure = () => new SlidingTtl(TimeSpan.MaxValue);
Action configure = () =>
{
SlidingTtl ttl = 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
Loading