< Summary

Information
Class: MyNet.Primitives.Conversion.LengthConverter
Assembly: MyNet.Primitives
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Conversion/LengthConverter.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 25
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
Convert(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Conversion/LengthConverter.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="LengthConverter.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8
 9namespace MyNet.Primitives.Conversion;
 10
 11/// <summary>
 12/// Provides conversion between different length units based on the metric system. The conversion is performed using pow
 13/// </summary>
 14public sealed class LengthConverter : IUnitConverter<LengthUnit>
 15{
 16    /// <summary>
 17    /// Converts a length value from one metric unit to another by applying the appropriate power of 10 based on the dif
 18    /// </summary>
 19    /// <param name="value">The length value to convert.</param>
 20    /// <param name="from">The unit of the input value.</param>
 21    /// <param name="to">The unit to convert the value to.</param>
 22    /// <returns>The converted length value.</returns>
 13223    public double Convert(double value, LengthUnit from, LengthUnit to) => value * Math.Pow(10, from - to);
 24}
 25