< Summary

Information
Class: MyNet.Primitives.Providers.PredicateItemsProvider<T>
Assembly: MyNet.Primitives
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Providers/PredicateItemsProvider.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 42
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetItemsAsync()100%44100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Providers/PredicateItemsProvider.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="PredicateItemsProvider.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Collections.Generic;
 9using System.Diagnostics.CodeAnalysis;
 10using System.Runtime.CompilerServices;
 11using System.Threading;
 12
 13namespace MyNet.Primitives.Providers;
 14
 15/// <summary>
 16/// Defines a class that implements the <see cref="IItemsProvider{T}"/> interface and provides a filtered collection of 
 17/// </summary>
 18/// <param name="provider">The underlying items provider.</param>
 19/// <param name="predicate">The predicate function used to filter items.</param>
 20/// <typeparam name="T">The type of items provided by the implementing class.</typeparam>
 21public class PredicateItemsProvider<T>(IItemsProvider<T> provider, Func<T, bool> predicate) : IItemsProvider<T>
 22{
 23    /// <summary>
 24    /// Initializes a new instance of the <see cref="PredicateItemsProvider{T}"/> class with the specified items and pre
 25    /// </summary>
 26    /// <param name="items">The collection of items to be filtered.</param>
 27    /// <param name="predicate">The predicate function used to filter items.</param>
 28    public PredicateItemsProvider(IEnumerable<T> items, Func<T, bool> predicate)
 629        : this(new ItemsProvider<T>(items), predicate) { }
 30
 31    /// <inheritdoc/>
 32    [SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "This 
 33    public async IAsyncEnumerable<T> GetItemsAsync([EnumeratorCancellation] CancellationToken cancellationToken = defaul
 34    {
 7835        await foreach (var item in provider.GetItemsAsync(cancellationToken))
 36        {
 2737            if (predicate(item))
 1238                yield return item;
 39        }
 640    }
 41}
 42