< Summary

Information
Class: FixedMathSharp.Assertions.Vector2dAssertions
Assembly: FixedMathSharp.FluentAssertions
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp.FluentAssertions/Vector2dAssertions.cs
Line coverage
100%
Covered lines: 37
Uncovered lines: 0
Coverable lines: 37
Total lines: 103
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
.ctor(...)100%11100%
get_Identifier()100%11100%
BeApproximately(...)100%11100%
NotBeApproximately(...)100%11100%
HaveComponentApproximately(...)100%11100%
HaveMagnitudeApproximately(...)100%11100%
BeNormalized(...)100%11100%

File(s)

/home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp.FluentAssertions/Vector2dAssertions.cs

#LineLine coverage
 1//=======================================================================
 2// Vector2dAssertions.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using FluentAssertions;
 9using FluentAssertions.Execution;
 10using FluentAssertions.Numeric;
 11
 12namespace FixedMathSharp.Assertions;
 13
 14public sealed class Vector2dAssertions : ComparableTypeAssertions<Vector2d, Vector2dAssertions>
 15{
 3416    public Vector2dAssertions(Vector2d value) : base(value, AssertionChain.GetOrCreate()) { }
 17
 118    protected override string Identifier => "vector2d";
 19
 20    public AndConstraint<Vector2dAssertions> BeApproximately(
 21        Vector2d expected,
 22        Fixed64? tolerance = null,
 23        string because = "",
 24        params object[] becauseArgs)
 25    {
 226        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 227        Vector2d actual = (Vector2d)Subject;
 28
 229        CurrentAssertionChain
 230            .ForCondition((actual - expected).Magnitude <= limit)
 231            .BecauseOf(because, becauseArgs)
 232            .FailWith("Expected vector2d to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, actu
 33
 134        return new AndConstraint<Vector2dAssertions>(this);
 35    }
 36
 37    public AndConstraint<Vector2dAssertions> NotBeApproximately(
 38        Vector2d expected,
 39        Fixed64? tolerance = null,
 40        string because = "",
 41        params object[] becauseArgs)
 42    {
 243        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 244        Vector2d actual = (Vector2d)Subject;
 45
 246        CurrentAssertionChain
 247            .ForCondition((actual - expected).Magnitude > limit)
 248            .BecauseOf(because, becauseArgs)
 249            .FailWith("Expected vector2d not to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, 
 50
 151        return new AndConstraint<Vector2dAssertions>(this);
 52    }
 53
 54    public AndConstraint<Vector2dAssertions> HaveComponentApproximately(
 55        Vector2d expected,
 56        Fixed64? tolerance = null,
 57        string because = "",
 58        params object[] becauseArgs)
 59    {
 460        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 461        Vector2d actual = (Vector2d)Subject;
 62
 463        CurrentAssertionChain
 464            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(actual, expected, limit))
 465            .BecauseOf(because, becauseArgs)
 466            .FailWith("Expected vector2d components to be approximately {0} +/- {1}{reason}, but found {2}.", expected, 
 67
 168        return new AndConstraint<Vector2dAssertions>(this);
 69    }
 70
 71    public AndConstraint<Vector2dAssertions> HaveMagnitudeApproximately(
 72        Fixed64 expected,
 73        Fixed64? tolerance = null,
 74        string because = "",
 75        params object[] becauseArgs)
 76    {
 277        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 278        Vector2d actual = (Vector2d)Subject;
 79
 280        CurrentAssertionChain
 281            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(actual.Magnitude, expected, limit))
 282            .BecauseOf(because, becauseArgs)
 283            .FailWith("Expected vector2d magnitude to be approximately {0} +/- {1}{reason}, but found {2}.", expected, l
 84
 185        return new AndConstraint<Vector2dAssertions>(this);
 86    }
 87
 88    public AndConstraint<Vector2dAssertions> BeNormalized(
 89        Fixed64? tolerance = null,
 90        string because = "",
 91        params object[] becauseArgs)
 92    {
 293        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 294        Vector2d actual = (Vector2d)Subject;
 95
 296        CurrentAssertionChain
 297            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(actual.Magnitude, Fixed64.One, limit))
 298            .BecauseOf(because, becauseArgs)
 299            .FailWith("Expected vector2d to be normalized within +/- {0}{reason}, but found magnitude {1}.", limit, actu
 100
 1101        return new AndConstraint<Vector2dAssertions>(this);
 102    }
 103}