< Summary - SonghayCore

Information
Class: Songhay.Extensions.ObservableCollectionExtensions
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/ObservableCollectionExtensions.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 43
Line coverage: 100%
Branch coverage
91%
Covered branches: 11
Total branches: 12
Branch coverage: 91.6%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
SetCollectionWithDigits(...)100%1100%
SetCollectionWithDigits(...)91.66%12100%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/ObservableCollectionExtensions.cs

#LineLine coverage
 1namespace Songhay.Extensions;
 2
 3/// <summary>
 4/// Extensions of <see cref="ObservableCollection&lt;T&gt;" />.
 5/// </summary>
 6public static class ObservableCollectionExtensions
 7{
 8    /// <summary>
 9    /// Sets the collection with digits for <c>mantissaDigits = 2</c>.
 10    /// </summary>
 11    /// <param name="collectionOfByte">The collection of byte.</param>
 12    /// <param name="digits">The digits.</param>
 13    public static void SetCollectionWithDigits(this ObservableCollection<byte?> collectionOfByte, double digits) =>
 214        collectionOfByte.SetCollectionWithDigits(digits, mantissaDigits: 2);
 15
 16    /// <summary>
 17    /// Sets the collection with digits.
 18    /// </summary>
 19    /// <param name="collectionOfByte">The collection of byte.</param>
 20    /// <param name="digits">The digits.</param>
 21    /// <param name="mantissaDigits">The mantissa digits.</param>
 22    public static void SetCollectionWithDigits(this ObservableCollection<byte?>? collectionOfByte, double digits,
 23        int mantissaDigits)
 224    {
 225        if (collectionOfByte == null) return;
 26
 227        var x = Convert.ToInt32(100 * MathUtility.GetMantissa(digits, mantissaDigits));
 228        if (collectionOfByte.Count < mantissaDigits) return;
 29
 230        collectionOfByte[0] = (x >= 1e0) ? MathUtility.GetDigitInNumber(x, 1) : 0;
 231        collectionOfByte[1] = (x >= 1e1) ? MathUtility.GetDigitInNumber(x, 2) : 0;
 32
 233        x = Convert.ToInt32(MathUtility.TruncateNumber(digits));
 34
 2835        for (int i = 2; i < collectionOfByte.Count; i++)
 1236        {
 1237            var place = i - 1;
 1238            var y = i - 2;
 39
 1240            collectionOfByte[i] = (x < Math.Pow(10, y)) ? 0 : MathUtility.GetDigitInNumber(x, place);
 1241        }
 242    }
 43}