< Summary

Information
Class: FixedMathSharp.Assertions.Vector3dAssertions
Assembly: FixedMathSharp.FluentAssertions
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp.FluentAssertions/Vector3dAssertions.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/Vector3dAssertions.cs

#LineLine coverage
 1//=======================================================================
 2// Vector3dAssertions.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 Vector3dAssertions : ComparableTypeAssertions<Vector3d, Vector3dAssertions>
 15{
 3616    public Vector3dAssertions(Vector3d value) : base(value, AssertionChain.GetOrCreate()) { }
 17
 118    protected override string Identifier => "vector3d";
 19
 20    public AndConstraint<Vector3dAssertions> BeApproximately(
 21        Vector3d expected,
 22        Fixed64? tolerance = null,
 23        string because = "",
 24        params object[] becauseArgs)
 25    {
 226        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 227        Vector3d actual = (Vector3d)Subject;
 28
 229        CurrentAssertionChain
 230            .ForCondition((actual - expected).Magnitude <= limit)
 231            .BecauseOf(because, becauseArgs)
 232            .FailWith("Expected vector3d to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, actu
 33
 134        return new AndConstraint<Vector3dAssertions>(this);
 35    }
 36
 37    public AndConstraint<Vector3dAssertions> NotBeApproximately(
 38        Vector3d expected,
 39        Fixed64? tolerance = null,
 40        string because = "",
 41        params object[] becauseArgs)
 42    {
 243        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 244        Vector3d actual = (Vector3d)Subject;
 45
 246        CurrentAssertionChain
 247            .ForCondition((actual - expected).Magnitude > limit)
 248            .BecauseOf(because, becauseArgs)
 249            .FailWith("Expected vector3d not to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, 
 50
 151        return new AndConstraint<Vector3dAssertions>(this);
 52    }
 53
 54    public AndConstraint<Vector3dAssertions> HaveComponentApproximately(
 55        Vector3d expected,
 56        Fixed64? tolerance = null,
 57        string because = "",
 58        params object[] becauseArgs)
 59    {
 560        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 561        Vector3d actual = (Vector3d)Subject;
 62
 563        CurrentAssertionChain
 564            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(actual, expected, limit))
 565            .BecauseOf(because, becauseArgs)
 566            .FailWith("Expected vector3d components to be approximately {0} +/- {1}{reason}, but found {2}.", expected, 
 67
 168        return new AndConstraint<Vector3dAssertions>(this);
 69    }
 70
 71    public AndConstraint<Vector3dAssertions> HaveMagnitudeApproximately(
 72        Fixed64 expected,
 73        Fixed64? tolerance = null,
 74        string because = "",
 75        params object[] becauseArgs)
 76    {
 277        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 278        Vector3d actual = (Vector3d)Subject;
 79
 280        CurrentAssertionChain
 281            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(actual.Magnitude, expected, limit))
 282            .BecauseOf(because, becauseArgs)
 283            .FailWith("Expected vector3d magnitude to be approximately {0} +/- {1}{reason}, but found {2}.", expected, l
 84
 185        return new AndConstraint<Vector3dAssertions>(this);
 86    }
 87
 88    public AndConstraint<Vector3dAssertions> BeNormalized(
 89        Fixed64? tolerance = null,
 90        string because = "",
 91        params object[] becauseArgs)
 92    {
 293        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 294        Vector3d actual = (Vector3d)Subject;
 95
 296        CurrentAssertionChain
 297            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(actual.Magnitude, Fixed64.One, limit))
 298            .BecauseOf(because, becauseArgs)
 299            .FailWith("Expected vector3d to be normalized within +/- {0}{reason}, but found magnitude {1}.", limit, actu
 100
 1101        return new AndConstraint<Vector3dAssertions>(this);
 102    }
 103}