< Summary

Information
Class: FixedMathSharp.Assertions.FixedStructAssertions<T1, T2>
Assembly: FixedMathSharp.FluentAssertions
File(s): /home/runner/work/FixedMathSharp/FixedMathSharp/src/FixedMathSharp.FluentAssertions/FixedAssertions.cs
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 705
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_Subject()100%11100%
get_CurrentAssertionChain()100%11100%
Be(...)100%11100%
NotBe(...)100%11100%

File(s)

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

#LineLine coverage
 1using FluentAssertions;
 2using FluentAssertions.Execution;
 3using FluentAssertions.Numeric;
 4
 5namespace FixedMathSharp.Assertions;
 6
 7internal static class FixedAssertionHelpers
 8{
 9    public static Fixed64 ResolveTolerance(Fixed64? tolerance)
 10    {
 11        return tolerance ?? Fixed64.Epsilon;
 12    }
 13
 14    public static bool AreApproximatelyEqual(Fixed64 actual, Fixed64 expected, Fixed64 tolerance)
 15    {
 16        return (actual - expected).Abs() <= tolerance;
 17    }
 18
 19    public static bool AreComponentApproximatelyEqual(Vector2d actual, Vector2d expected, Fixed64 tolerance)
 20    {
 21        return (actual.x - expected.x).Abs() <= tolerance
 22            && (actual.y - expected.y).Abs() <= tolerance;
 23    }
 24
 25    public static bool AreComponentApproximatelyEqual(Vector3d actual, Vector3d expected, Fixed64 tolerance)
 26    {
 27        return (actual.x - expected.x).Abs() <= tolerance
 28            && (actual.y - expected.y).Abs() <= tolerance
 29            && (actual.z - expected.z).Abs() <= tolerance;
 30    }
 31
 32    public static bool AreComponentApproximatelyEqual(FixedQuaternion actual, FixedQuaternion expected, Fixed64 toleranc
 33    {
 34        return (actual.x - expected.x).Abs() <= tolerance
 35            && (actual.y - expected.y).Abs() <= tolerance
 36            && (actual.z - expected.z).Abs() <= tolerance
 37            && (actual.w - expected.w).Abs() <= tolerance;
 38    }
 39
 40    public static bool AreComponentApproximatelyEqual(Fixed3x3 actual, Fixed3x3 expected, Fixed64 tolerance)
 41    {
 42        return (actual.m00 - expected.m00).Abs() <= tolerance
 43            && (actual.m01 - expected.m01).Abs() <= tolerance
 44            && (actual.m02 - expected.m02).Abs() <= tolerance
 45            && (actual.m10 - expected.m10).Abs() <= tolerance
 46            && (actual.m11 - expected.m11).Abs() <= tolerance
 47            && (actual.m12 - expected.m12).Abs() <= tolerance
 48            && (actual.m20 - expected.m20).Abs() <= tolerance
 49            && (actual.m21 - expected.m21).Abs() <= tolerance
 50            && (actual.m22 - expected.m22).Abs() <= tolerance;
 51    }
 52
 53    public static bool AreComponentApproximatelyEqual(Fixed4x4 actual, Fixed4x4 expected, Fixed64 tolerance)
 54    {
 55        return (actual.m00 - expected.m00).Abs() <= tolerance
 56            && (actual.m01 - expected.m01).Abs() <= tolerance
 57            && (actual.m02 - expected.m02).Abs() <= tolerance
 58            && (actual.m03 - expected.m03).Abs() <= tolerance
 59            && (actual.m10 - expected.m10).Abs() <= tolerance
 60            && (actual.m11 - expected.m11).Abs() <= tolerance
 61            && (actual.m12 - expected.m12).Abs() <= tolerance
 62            && (actual.m13 - expected.m13).Abs() <= tolerance
 63            && (actual.m20 - expected.m20).Abs() <= tolerance
 64            && (actual.m21 - expected.m21).Abs() <= tolerance
 65            && (actual.m22 - expected.m22).Abs() <= tolerance
 66            && (actual.m23 - expected.m23).Abs() <= tolerance
 67            && (actual.m30 - expected.m30).Abs() <= tolerance
 68            && (actual.m31 - expected.m31).Abs() <= tolerance
 69            && (actual.m32 - expected.m32).Abs() <= tolerance
 70            && (actual.m33 - expected.m33).Abs() <= tolerance;
 71    }
 72
 73    public static bool RepresentsSameRotation(FixedQuaternion actual, FixedQuaternion expected, Fixed64 tolerance)
 74    {
 75        FixedQuaternion normalizedActual = FixedQuaternion.GetNormalized(actual);
 76        FixedQuaternion normalizedExpected = FixedQuaternion.GetNormalized(expected);
 77        Fixed64 alignment = FixedMath.Abs(FixedQuaternion.Dot(normalizedActual, normalizedExpected));
 78        return FixedMath.Abs(Fixed64.One - alignment) <= tolerance;
 79    }
 80
 81    public static bool HasUnitAxes(Fixed3x3 matrix, Fixed64 tolerance)
 82    {
 83        return AreApproximatelyEqual(new Vector3d(matrix.m00, matrix.m01, matrix.m02).Magnitude, Fixed64.One, tolerance)
 84            && AreApproximatelyEqual(new Vector3d(matrix.m10, matrix.m11, matrix.m12).Magnitude, Fixed64.One, tolerance)
 85            && AreApproximatelyEqual(new Vector3d(matrix.m20, matrix.m21, matrix.m22).Magnitude, Fixed64.One, tolerance)
 86    }
 87
 88    public static bool HasUnitAxes(Fixed4x4 matrix, Fixed64 tolerance)
 89    {
 90        return AreApproximatelyEqual(new Vector3d(matrix.m00, matrix.m01, matrix.m02).Magnitude, Fixed64.One, tolerance)
 91            && AreApproximatelyEqual(new Vector3d(matrix.m10, matrix.m11, matrix.m12).Magnitude, Fixed64.One, tolerance)
 92            && AreApproximatelyEqual(new Vector3d(matrix.m20, matrix.m21, matrix.m22).Magnitude, Fixed64.One, tolerance)
 93    }
 94}
 95
 96public abstract class FixedStructAssertions<TSubject, TAssertions>
 97    where TAssertions : FixedStructAssertions<TSubject, TAssertions>
 98{
 4499    protected FixedStructAssertions(TSubject value)
 44100    {
 44101        Subject = value;
 44102        CurrentAssertionChain = AssertionChain.GetOrCreate();
 44103    }
 104
 78105    protected TSubject Subject { get; }
 106
 44107    protected AssertionChain CurrentAssertionChain { get; }
 108
 109    protected abstract string Identifier { get; }
 110
 111    public AndConstraint<TAssertions> Be(TSubject expected, string because = "", params object[] becauseArgs)
 8112    {
 8113        CurrentAssertionChain
 8114            .ForCondition(Equals(Subject, expected))
 8115            .BecauseOf(because, becauseArgs)
 8116            .FailWith("Expected " + Identifier + " to equal {0}{reason}, but found {1}.", expected, Subject);
 117
 4118        return new AndConstraint<TAssertions>((TAssertions)this);
 4119    }
 120
 121    public AndConstraint<TAssertions> NotBe(TSubject unexpected, string because = "", params object[] becauseArgs)
 6122    {
 6123        CurrentAssertionChain
 6124            .ForCondition(!Equals(Subject, unexpected))
 6125            .BecauseOf(because, becauseArgs)
 6126            .FailWith("Expected " + Identifier + " not to equal {0}{reason}, but found {1}.", unexpected, Subject);
 127
 3128        return new AndConstraint<TAssertions>((TAssertions)this);
 3129    }
 130}
 131
 132public sealed class Fixed64Assertions : ComparableTypeAssertions<Fixed64, Fixed64Assertions>
 133{
 134    public Fixed64Assertions(Fixed64 value) : base(value, AssertionChain.GetOrCreate()) { }
 135
 136    protected override string Identifier => "fixed64";
 137
 138    public AndConstraint<Fixed64Assertions> BeApproximately(
 139        Fixed64 expected,
 140        Fixed64? tolerance = null,
 141        string because = "",
 142        params object[] becauseArgs)
 143    {
 144        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 145        Fixed64 actual = (Fixed64)Subject;
 146
 147        CurrentAssertionChain
 148            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(actual, expected, limit))
 149            .BecauseOf(because, becauseArgs)
 150            .FailWith("Expected fixed64 to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, actua
 151
 152        return new AndConstraint<Fixed64Assertions>(this);
 153    }
 154
 155    public AndConstraint<Fixed64Assertions> NotBeApproximately(
 156        Fixed64 expected,
 157        Fixed64? tolerance = null,
 158        string because = "",
 159        params object[] becauseArgs)
 160    {
 161        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 162        Fixed64 actual = (Fixed64)Subject;
 163
 164        CurrentAssertionChain
 165            .ForCondition((actual - expected).Abs() > limit)
 166            .BecauseOf(because, becauseArgs)
 167            .FailWith("Expected fixed64 not to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, a
 168
 169        return new AndConstraint<Fixed64Assertions>(this);
 170    }
 171
 172    public AndConstraint<Fixed64Assertions> HaveRawValue(
 173        long expected,
 174        string because = "",
 175        params object[] becauseArgs)
 176    {
 177        Fixed64 actual = (Fixed64)Subject;
 178
 179        CurrentAssertionChain
 180            .ForCondition(actual.m_rawValue == expected)
 181            .BecauseOf(because, becauseArgs)
 182            .FailWith("Expected fixed64 to have raw value {0}{reason}, but found {1}.", expected, actual.m_rawValue);
 183
 184        return new AndConstraint<Fixed64Assertions>(this);
 185    }
 186}
 187
 188public static class Fixed64AssertionsExtensions
 189{
 190    public static Fixed64Assertions Should(this Fixed64 actualValue)
 191    {
 192        return new Fixed64Assertions(actualValue);
 193    }
 194}
 195
 196public sealed class Vector2dAssertions : ComparableTypeAssertions<Vector2d, Vector2dAssertions>
 197{
 198    public Vector2dAssertions(Vector2d value) : base(value, AssertionChain.GetOrCreate()) { }
 199
 200    protected override string Identifier => "vector2d";
 201
 202    public AndConstraint<Vector2dAssertions> BeApproximately(
 203        Vector2d expected,
 204        Fixed64? tolerance = null,
 205        string because = "",
 206        params object[] becauseArgs)
 207    {
 208        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 209        Vector2d actual = (Vector2d)Subject;
 210
 211        CurrentAssertionChain
 212            .ForCondition((actual - expected).Magnitude <= limit)
 213            .BecauseOf(because, becauseArgs)
 214            .FailWith("Expected vector2d to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, actu
 215
 216        return new AndConstraint<Vector2dAssertions>(this);
 217    }
 218
 219    public AndConstraint<Vector2dAssertions> NotBeApproximately(
 220        Vector2d expected,
 221        Fixed64? tolerance = null,
 222        string because = "",
 223        params object[] becauseArgs)
 224    {
 225        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 226        Vector2d actual = (Vector2d)Subject;
 227
 228        CurrentAssertionChain
 229            .ForCondition((actual - expected).Magnitude > limit)
 230            .BecauseOf(because, becauseArgs)
 231            .FailWith("Expected vector2d not to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, 
 232
 233        return new AndConstraint<Vector2dAssertions>(this);
 234    }
 235
 236    public AndConstraint<Vector2dAssertions> HaveComponentApproximately(
 237        Vector2d expected,
 238        Fixed64? tolerance = null,
 239        string because = "",
 240        params object[] becauseArgs)
 241    {
 242        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 243        Vector2d actual = (Vector2d)Subject;
 244
 245        CurrentAssertionChain
 246            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(actual, expected, limit))
 247            .BecauseOf(because, becauseArgs)
 248            .FailWith("Expected vector2d components to be approximately {0} +/- {1}{reason}, but found {2}.", expected, 
 249
 250        return new AndConstraint<Vector2dAssertions>(this);
 251    }
 252
 253    public AndConstraint<Vector2dAssertions> HaveMagnitudeApproximately(
 254        Fixed64 expected,
 255        Fixed64? tolerance = null,
 256        string because = "",
 257        params object[] becauseArgs)
 258    {
 259        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 260        Vector2d actual = (Vector2d)Subject;
 261
 262        CurrentAssertionChain
 263            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(actual.Magnitude, expected, limit))
 264            .BecauseOf(because, becauseArgs)
 265            .FailWith("Expected vector2d magnitude to be approximately {0} +/- {1}{reason}, but found {2}.", expected, l
 266
 267        return new AndConstraint<Vector2dAssertions>(this);
 268    }
 269
 270    public AndConstraint<Vector2dAssertions> BeNormalized(
 271        Fixed64? tolerance = null,
 272        string because = "",
 273        params object[] becauseArgs)
 274    {
 275        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 276        Vector2d actual = (Vector2d)Subject;
 277
 278        CurrentAssertionChain
 279            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(actual.Magnitude, Fixed64.One, limit))
 280            .BecauseOf(because, becauseArgs)
 281            .FailWith("Expected vector2d to be normalized within +/- {0}{reason}, but found magnitude {1}.", limit, actu
 282
 283        return new AndConstraint<Vector2dAssertions>(this);
 284    }
 285}
 286
 287public static class Vector2dAssertionsExtensions
 288{
 289    public static Vector2dAssertions Should(this Vector2d actualValue)
 290    {
 291        return new Vector2dAssertions(actualValue);
 292    }
 293}
 294
 295public sealed class Vector3dAssertions : ComparableTypeAssertions<Vector3d, Vector3dAssertions>
 296{
 297    public Vector3dAssertions(Vector3d value) : base(value, AssertionChain.GetOrCreate()) { }
 298
 299    protected override string Identifier => "vector3d";
 300
 301    public AndConstraint<Vector3dAssertions> BeApproximately(
 302        Vector3d expected,
 303        Fixed64? tolerance = null,
 304        string because = "",
 305        params object[] becauseArgs)
 306    {
 307        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 308        Vector3d actual = (Vector3d)Subject;
 309
 310        CurrentAssertionChain
 311            .ForCondition((actual - expected).Magnitude <= limit)
 312            .BecauseOf(because, becauseArgs)
 313            .FailWith("Expected vector3d to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, actu
 314
 315        return new AndConstraint<Vector3dAssertions>(this);
 316    }
 317
 318    public AndConstraint<Vector3dAssertions> NotBeApproximately(
 319        Vector3d expected,
 320        Fixed64? tolerance = null,
 321        string because = "",
 322        params object[] becauseArgs)
 323    {
 324        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 325        Vector3d actual = (Vector3d)Subject;
 326
 327        CurrentAssertionChain
 328            .ForCondition((actual - expected).Magnitude > limit)
 329            .BecauseOf(because, becauseArgs)
 330            .FailWith("Expected vector3d not to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limit, 
 331
 332        return new AndConstraint<Vector3dAssertions>(this);
 333    }
 334
 335    public AndConstraint<Vector3dAssertions> HaveComponentApproximately(
 336        Vector3d expected,
 337        Fixed64? tolerance = null,
 338        string because = "",
 339        params object[] becauseArgs)
 340    {
 341        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 342        Vector3d actual = (Vector3d)Subject;
 343
 344        CurrentAssertionChain
 345            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(actual, expected, limit))
 346            .BecauseOf(because, becauseArgs)
 347            .FailWith("Expected vector3d components to be approximately {0} +/- {1}{reason}, but found {2}.", expected, 
 348
 349        return new AndConstraint<Vector3dAssertions>(this);
 350    }
 351
 352    public AndConstraint<Vector3dAssertions> HaveMagnitudeApproximately(
 353        Fixed64 expected,
 354        Fixed64? tolerance = null,
 355        string because = "",
 356        params object[] becauseArgs)
 357    {
 358        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 359        Vector3d actual = (Vector3d)Subject;
 360
 361        CurrentAssertionChain
 362            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(actual.Magnitude, expected, limit))
 363            .BecauseOf(because, becauseArgs)
 364            .FailWith("Expected vector3d magnitude to be approximately {0} +/- {1}{reason}, but found {2}.", expected, l
 365
 366        return new AndConstraint<Vector3dAssertions>(this);
 367    }
 368
 369    public AndConstraint<Vector3dAssertions> BeNormalized(
 370        Fixed64? tolerance = null,
 371        string because = "",
 372        params object[] becauseArgs)
 373    {
 374        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 375        Vector3d actual = (Vector3d)Subject;
 376
 377        CurrentAssertionChain
 378            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(actual.Magnitude, Fixed64.One, limit))
 379            .BecauseOf(because, becauseArgs)
 380            .FailWith("Expected vector3d to be normalized within +/- {0}{reason}, but found magnitude {1}.", limit, actu
 381
 382        return new AndConstraint<Vector3dAssertions>(this);
 383    }
 384}
 385
 386public static class Vector3dAssertionsExtensions
 387{
 388    public static Vector3dAssertions Should(this Vector3d actualValue)
 389    {
 390        return new Vector3dAssertions(actualValue);
 391    }
 392}
 393
 394public sealed class FixedQuaternionAssertions : FixedStructAssertions<FixedQuaternion, FixedQuaternionAssertions>
 395{
 396    public FixedQuaternionAssertions(FixedQuaternion value) : base(value) { }
 397
 398    protected override string Identifier => "fixed quaternion";
 399
 400    public AndConstraint<FixedQuaternionAssertions> BeApproximately(
 401        FixedQuaternion expected,
 402        Fixed64? tolerance = null,
 403        string because = "",
 404        params object[] becauseArgs)
 405    {
 406        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 407
 408        CurrentAssertionChain
 409            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(Subject, expected, limit))
 410            .BecauseOf(because, becauseArgs)
 411            .FailWith("Expected fixed quaternion components to be approximately {0} +/- {1}{reason}, but found {2}.", ex
 412
 413        return new AndConstraint<FixedQuaternionAssertions>(this);
 414    }
 415
 416    public AndConstraint<FixedQuaternionAssertions> NotBeApproximately(
 417        FixedQuaternion expected,
 418        Fixed64? tolerance = null,
 419        string because = "",
 420        params object[] becauseArgs)
 421    {
 422        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 423
 424        CurrentAssertionChain
 425            .ForCondition(!FixedAssertionHelpers.AreComponentApproximatelyEqual(Subject, expected, limit))
 426            .BecauseOf(because, becauseArgs)
 427            .FailWith("Expected fixed quaternion not to be approximately {0} +/- {1}{reason}, but found {2}.", expected,
 428
 429        return new AndConstraint<FixedQuaternionAssertions>(this);
 430    }
 431
 432    public AndConstraint<FixedQuaternionAssertions> HaveComponentApproximately(
 433        FixedQuaternion expected,
 434        Fixed64? tolerance = null,
 435        string because = "",
 436        params object[] becauseArgs)
 437    {
 438        return BeApproximately(expected, tolerance, because, becauseArgs);
 439    }
 440
 441    public AndConstraint<FixedQuaternionAssertions> RepresentSameRotationAs(
 442        FixedQuaternion expected,
 443        Fixed64? tolerance = null,
 444        string because = "",
 445        params object[] becauseArgs)
 446    {
 447        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 448
 449        CurrentAssertionChain
 450            .ForCondition(FixedAssertionHelpers.RepresentsSameRotation(Subject, expected, limit))
 451            .BecauseOf(because, becauseArgs)
 452            .FailWith("Expected fixed quaternion to represent the same rotation as {0} +/- {1}{reason}, but found {2}.",
 453
 454        return new AndConstraint<FixedQuaternionAssertions>(this);
 455    }
 456
 457    public AndConstraint<FixedQuaternionAssertions> BeIdentity(
 458        string because = "",
 459        params object[] becauseArgs)
 460    {
 461        return Be(FixedQuaternion.Identity, because, becauseArgs);
 462    }
 463
 464    public AndConstraint<FixedQuaternionAssertions> BeNormalized(
 465        Fixed64? tolerance = null,
 466        string because = "",
 467        params object[] becauseArgs)
 468    {
 469        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 470        Fixed64 magnitude = FixedQuaternion.GetMagnitude(Subject);
 471
 472        CurrentAssertionChain
 473            .ForCondition(FixedAssertionHelpers.AreApproximatelyEqual(magnitude, Fixed64.One, limit))
 474            .BecauseOf(because, becauseArgs)
 475            .FailWith("Expected fixed quaternion to be normalized within +/- {0}{reason}, but found magnitude {1}.", lim
 476
 477        return new AndConstraint<FixedQuaternionAssertions>(this);
 478    }
 479}
 480
 481public static class FixedQuaternionAssertionsExtensions
 482{
 483    public static FixedQuaternionAssertions Should(this FixedQuaternion actualValue)
 484    {
 485        return new FixedQuaternionAssertions(actualValue);
 486    }
 487}
 488
 489public sealed class Fixed3x3Assertions : FixedStructAssertions<Fixed3x3, Fixed3x3Assertions>
 490{
 491    public Fixed3x3Assertions(Fixed3x3 value) : base(value) { }
 492
 493    protected override string Identifier => "fixed3x3 matrix";
 494
 495    public AndConstraint<Fixed3x3Assertions> BeApproximately(
 496        Fixed3x3 expected,
 497        Fixed64? tolerance = null,
 498        string because = "",
 499        params object[] becauseArgs)
 500    {
 501        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 502
 503        CurrentAssertionChain
 504            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(Subject, expected, limit))
 505            .BecauseOf(because, becauseArgs)
 506            .FailWith("Expected fixed3x3 matrix to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limi
 507
 508        return new AndConstraint<Fixed3x3Assertions>(this);
 509    }
 510
 511    public AndConstraint<Fixed3x3Assertions> NotBeApproximately(
 512        Fixed3x3 expected,
 513        Fixed64? tolerance = null,
 514        string because = "",
 515        params object[] becauseArgs)
 516    {
 517        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 518
 519        CurrentAssertionChain
 520            .ForCondition(!FixedAssertionHelpers.AreComponentApproximatelyEqual(Subject, expected, limit))
 521            .BecauseOf(because, becauseArgs)
 522            .FailWith("Expected fixed3x3 matrix not to be approximately {0} +/- {1}{reason}, but found {2}.", expected, 
 523
 524        return new AndConstraint<Fixed3x3Assertions>(this);
 525    }
 526
 527    public AndConstraint<Fixed3x3Assertions> BeIdentity(
 528        string because = "",
 529        params object[] becauseArgs)
 530    {
 531        return Be(Fixed3x3.Identity, because, becauseArgs);
 532    }
 533
 534    public AndConstraint<Fixed3x3Assertions> HaveScaleApproximately(
 535        Vector3d expected,
 536        Fixed64? tolerance = null,
 537        string because = "",
 538        params object[] becauseArgs)
 539    {
 540        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 541        Vector3d scale = Fixed3x3.ExtractScale(Subject);
 542
 543        CurrentAssertionChain
 544            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(scale, expected, limit))
 545            .BecauseOf(because, becauseArgs)
 546            .FailWith("Expected fixed3x3 matrix scale to be approximately {0} +/- {1}{reason}, but found {2}.", expected
 547
 548        return new AndConstraint<Fixed3x3Assertions>(this);
 549    }
 550
 551    public AndConstraint<Fixed3x3Assertions> HaveNormalizedAxes(
 552        Fixed64? tolerance = null,
 553        string because = "",
 554        params object[] becauseArgs)
 555    {
 556        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 557
 558        CurrentAssertionChain
 559            .ForCondition(FixedAssertionHelpers.HasUnitAxes(Subject, limit))
 560            .BecauseOf(because, becauseArgs)
 561            .FailWith("Expected fixed3x3 matrix axes to be normalized within +/- {0}{reason}, but found {1}.", limit, Su
 562
 563        return new AndConstraint<Fixed3x3Assertions>(this);
 564    }
 565}
 566
 567public static class Fixed3x3AssertionsExtensions
 568{
 569    public static Fixed3x3Assertions Should(this Fixed3x3 actualValue)
 570    {
 571        return new Fixed3x3Assertions(actualValue);
 572    }
 573}
 574
 575public sealed class Fixed4x4Assertions : FixedStructAssertions<Fixed4x4, Fixed4x4Assertions>
 576{
 577    public Fixed4x4Assertions(Fixed4x4 value) : base(value) { }
 578
 579    protected override string Identifier => "fixed4x4 matrix";
 580
 581    public AndConstraint<Fixed4x4Assertions> BeApproximately(
 582        Fixed4x4 expected,
 583        Fixed64? tolerance = null,
 584        string because = "",
 585        params object[] becauseArgs)
 586    {
 587        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 588
 589        CurrentAssertionChain
 590            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(Subject, expected, limit))
 591            .BecauseOf(because, becauseArgs)
 592            .FailWith("Expected fixed4x4 matrix to be approximately {0} +/- {1}{reason}, but found {2}.", expected, limi
 593
 594        return new AndConstraint<Fixed4x4Assertions>(this);
 595    }
 596
 597    public AndConstraint<Fixed4x4Assertions> NotBeApproximately(
 598        Fixed4x4 expected,
 599        Fixed64? tolerance = null,
 600        string because = "",
 601        params object[] becauseArgs)
 602    {
 603        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 604
 605        CurrentAssertionChain
 606            .ForCondition(!FixedAssertionHelpers.AreComponentApproximatelyEqual(Subject, expected, limit))
 607            .BecauseOf(because, becauseArgs)
 608            .FailWith("Expected fixed4x4 matrix not to be approximately {0} +/- {1}{reason}, but found {2}.", expected, 
 609
 610        return new AndConstraint<Fixed4x4Assertions>(this);
 611    }
 612
 613    public AndConstraint<Fixed4x4Assertions> BeIdentity(
 614        string because = "",
 615        params object[] becauseArgs)
 616    {
 617        return Be(Fixed4x4.Identity, because, becauseArgs);
 618    }
 619
 620    public AndConstraint<Fixed4x4Assertions> BeAffine(
 621        string because = "",
 622        params object[] becauseArgs)
 623    {
 624        CurrentAssertionChain
 625            .ForCondition(Subject.IsAffine)
 626            .BecauseOf(because, becauseArgs)
 627            .FailWith("Expected fixed4x4 matrix to be affine{reason}, but found {0}.", Subject);
 628
 629        return new AndConstraint<Fixed4x4Assertions>(this);
 630    }
 631
 632    public AndConstraint<Fixed4x4Assertions> HaveTranslationApproximately(
 633        Vector3d expected,
 634        Fixed64? tolerance = null,
 635        string because = "",
 636        params object[] becauseArgs)
 637    {
 638        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 639        Vector3d translation = Subject.Translation;
 640
 641        CurrentAssertionChain
 642            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(translation, expected, limit))
 643            .BecauseOf(because, becauseArgs)
 644            .FailWith("Expected fixed4x4 matrix translation to be approximately {0} +/- {1}{reason}, but found {2}.", ex
 645
 646        return new AndConstraint<Fixed4x4Assertions>(this);
 647    }
 648
 649    public AndConstraint<Fixed4x4Assertions> HaveScaleApproximately(
 650        Vector3d expected,
 651        Fixed64? tolerance = null,
 652        string because = "",
 653        params object[] becauseArgs)
 654    {
 655        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 656        Vector3d scale = Subject.Scale;
 657
 658        CurrentAssertionChain
 659            .ForCondition(FixedAssertionHelpers.AreComponentApproximatelyEqual(scale, expected, limit))
 660            .BecauseOf(because, becauseArgs)
 661            .FailWith("Expected fixed4x4 matrix scale to be approximately {0} +/- {1}{reason}, but found {2}.", expected
 662
 663        return new AndConstraint<Fixed4x4Assertions>(this);
 664    }
 665
 666    public AndConstraint<Fixed4x4Assertions> HaveRotationApproximately(
 667        FixedQuaternion expected,
 668        Fixed64? tolerance = null,
 669        string because = "",
 670        params object[] becauseArgs)
 671    {
 672        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 673        FixedQuaternion rotation = Subject.Rotation;
 674
 675        CurrentAssertionChain
 676            .ForCondition(FixedAssertionHelpers.RepresentsSameRotation(rotation, expected, limit))
 677            .BecauseOf(because, becauseArgs)
 678            .FailWith("Expected fixed4x4 matrix rotation to be approximately {0} +/- {1}{reason}, but found {2}.", expec
 679
 680        return new AndConstraint<Fixed4x4Assertions>(this);
 681    }
 682
 683    public AndConstraint<Fixed4x4Assertions> HaveNormalizedRotationBasis(
 684        Fixed64? tolerance = null,
 685        string because = "",
 686        params object[] becauseArgs)
 687    {
 688        Fixed64 limit = FixedAssertionHelpers.ResolveTolerance(tolerance);
 689
 690        CurrentAssertionChain
 691            .ForCondition(FixedAssertionHelpers.HasUnitAxes(Subject, limit))
 692            .BecauseOf(because, becauseArgs)
 693            .FailWith("Expected fixed4x4 matrix rotation basis to be normalized within +/- {0}{reason}, but found {1}.",
 694
 695        return new AndConstraint<Fixed4x4Assertions>(this);
 696    }
 697}
 698
 699public static class Fixed4x4AssertionsExtensions
 700{
 701    public static Fixed4x4Assertions Should(this Fixed4x4 actualValue)
 702    {
 703        return new Fixed4x4Assertions(actualValue);
 704    }
 705}