Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal class ComponentWithDisposeCallbacks : PipelineComponent
public ComponentWithDisposeCallbacks(PipelineComponent component, List<Action> callbacks)
{
Component = component;
_callbacks = callbacks.ToList();
_callbacks = callbacks;
}

internal PipelineComponent Component { get; }
Expand Down
6 changes: 3 additions & 3 deletions src/Polly.Core/Utils/Pipeline/PipelineComponentFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ internal static class PipelineComponentFactory

public static PipelineComponent FromStrategy<T>(ResilienceStrategy<T> strategy) => new BridgeComponent<T>(strategy);

public static PipelineComponent WithDisposableCallbacks(PipelineComponent component, List<Action> callbacks)
public static PipelineComponent WithDisposableCallbacks(PipelineComponent component, IEnumerable<Action> callbacks)
{
if (callbacks.Count == 0)
if (!callbacks.Any())
{
return component;
}

return new ComponentWithDisposeCallbacks(component, callbacks);
return new ComponentWithDisposeCallbacks(component, callbacks.ToList());
}

public static PipelineComponent CreateComposite(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task Dispose_Ok(bool isAsync)
}

// Assert
callbacks.Should().HaveCount(2);
callbacks.Should().BeEmpty();
called1.Should().Be(1);
called2.Should().Be(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void WithDisposableCallbacks_NoCallbacks_ReturnsOriginalComponent()
public void PipelineComponentFactory_Should_Return_WrapperComponent_With_Callbacks()
{
var component = Substitute.For<PipelineComponent>();
List<Action> callbacks = new List<Action> { () => { } };
var callbacks = new List<Action> { () => { } };

var result = PipelineComponentFactory.WithDisposableCallbacks(component, callbacks);

Expand Down