< Summary

Information
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 38
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Statistics(...)100%11100%
Statistics(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Observable/Collections/Extensions/StatisticsExtensions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="StatisticsExtensions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using MyNet.Observable.Collections;
 9using MyNet.Observable.Collections.Statistics;
 10
 11#pragma warning disable IDE0130 // Namespace does not match folder structure
 12namespace MyNet.Observable;
 13#pragma warning restore IDE0130 // Namespace does not match folder structure
 14
 15/// <summary>
 16/// Creates reactive statistics over an <see cref="ExtendedCollection{T}"/> filtered view.
 17/// </summary>
 18public static class StatisticsExtensions
 19{
 20    extension<T>(ExtendedCollection<T> collection)
 21        where T : notnull
 22    {
 23        /// <summary>
 24        /// Tracks view metrics and numeric aggregates (sum, average, min, max) over the filtered view.
 25        /// </summary>
 26        /// <param name="valueSelector">Selects the numeric value for each item.</param>
 27        public CollectionStatistics<T, double> Statistics(Func<T, double> valueSelector) =>
 1228            CollectionStatistics<T, double>.ForDouble(collection, valueSelector);
 29
 30        /// <summary>
 31        /// Tracks view metrics and <see cref="TimeSpan"/> aggregates over the filtered view.
 32        /// </summary>
 33        /// <param name="valueSelector">Selects the duration for each item.</param>
 34        public CollectionStatistics<T, TimeSpan> Statistics(Func<T, TimeSpan> valueSelector) =>
 335            CollectionStatistics<T, TimeSpan>.ForTimeSpan(collection, valueSelector);
 36    }
 37}
 38