From 8dd3e732471df1a5e22911cfab4aa72828a16501 Mon Sep 17 00:00:00 2001 From: Manuel Rauber Date: Wed, 22 Feb 2023 09:07:36 +0100 Subject: [PATCH 1/3] chore: update to Unity 2021.3.19f1 --- FluentAssertions/Packages/manifest.json | 6 +++--- FluentAssertions/Packages/packages-lock.json | 21 ++++--------------- .../ProjectSettings/ProjectVersion.txt | 4 ++-- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/FluentAssertions/Packages/manifest.json b/FluentAssertions/Packages/manifest.json index e957786..349ad45 100644 --- a/FluentAssertions/Packages/manifest.json +++ b/FluentAssertions/Packages/manifest.json @@ -4,10 +4,10 @@ "com.unity.2d.tilemap": "1.0.0", "com.unity.ads": "3.7.5", "com.unity.analytics": "3.6.12", - "com.unity.collab-proxy": "1.17.2", + "com.unity.collab-proxy": "2.0.0", "com.unity.ext.nunit": "1.0.6", - "com.unity.ide.rider": "3.0.17", - "com.unity.ide.visualstudio": "2.0.16", + "com.unity.ide.rider": "3.0.18", + "com.unity.ide.visualstudio": "2.0.17", "com.unity.ide.vscode": "1.2.5", "com.unity.test-framework": "1.3.2", "com.unity.textmeshpro": "3.0.6", diff --git a/FluentAssertions/Packages/packages-lock.json b/FluentAssertions/Packages/packages-lock.json index a80aae0..2ac42e5 100644 --- a/FluentAssertions/Packages/packages-lock.json +++ b/FluentAssertions/Packages/packages-lock.json @@ -37,12 +37,10 @@ "url": "https://packages.unity.com" }, "com.unity.collab-proxy": { - "version": "1.17.2", + "version": "2.0.0", "depth": 0, "source": "registry", - "dependencies": { - "com.unity.services.core": "1.0.1" - }, + "dependencies": {}, "url": "https://packages.unity.com" }, "com.unity.ext.nunit": { @@ -53,7 +51,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.rider": { - "version": "3.0.17", + "version": "3.0.18", "depth": 0, "source": "registry", "dependencies": { @@ -62,7 +60,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.16", + "version": "2.0.17", "depth": 0, "source": "registry", "dependencies": { @@ -100,17 +98,6 @@ }, "url": "https://packages.unity.com" }, - "com.unity.services.core": { - "version": "1.4.2", - "depth": 1, - "source": "registry", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.nuget.newtonsoft-json": "3.0.2", - "com.unity.modules.androidjni": "1.0.0" - }, - "url": "https://packages.unity.com" - }, "com.unity.test-framework": { "version": "1.3.2", "depth": 0, diff --git a/FluentAssertions/ProjectSettings/ProjectVersion.txt b/FluentAssertions/ProjectSettings/ProjectVersion.txt index 8ea1b85..8e3af85 100644 --- a/FluentAssertions/ProjectSettings/ProjectVersion.txt +++ b/FluentAssertions/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.11f1 -m_EditorVersionWithRevision: 2021.3.11f1 (0a5ca18544bf) +m_EditorVersion: 2021.3.19f1 +m_EditorVersionWithRevision: 2021.3.19f1 (c9714fde33b6) From d3e0f3a42f08e3fba1a0887dbd83b2b14c96b6b3 Mon Sep 17 00:00:00 2001 From: Manuel Rauber Date: Wed, 22 Feb 2023 13:31:55 +0100 Subject: [PATCH 2/3] feat: ground work for integration Unity types into FluentAssertions --- .../Assembly-CSharp.csproj.DotSettings | 2 + ...Assertions.Editor.Tests.csproj.DotSettings | 3 + ...athematics.Editor.Tests.csproj.DotSettings | 4 + ...tAssertions.Mathematics.csproj.DotSettings | 4 + ...tudios.FluentAssertions.csproj.DotSettings | 4 + .../BoundfoxStudios.FluentAssertions.asmdef | 4 +- .../AppSettingsConfigurationStore.cs | 6 +- .../Runtime/UnityAdoption/Assertions.meta | 3 + .../Assertions/MathematicsAssertions.cs | 158 +++++ .../Assertions/MathematicsAssertions.cs.meta | 3 + .../NullableMathematicsAssertions.cs | 61 ++ .../NullableMathematicsAssertions.cs.meta | 3 + .../Runtime/UnityAdoption/Extensions.meta | 3 + .../Extensions/NullableVector3Extensions.cs | 15 + .../NullableVector3Extensions.cs.meta | 3 + .../Extensions/Vector3Extensions.cs | 15 + .../Extensions/Vector3Extensions.cs.meta | 3 + .../Runtime/UnityAdoption/Guard.cs | 15 + .../Runtime/UnityAdoption/Guard.cs.meta | 3 + .../Runtime/UnityAdoption/Mathematics.meta | 8 + ...tudios.FluentAssertions.Mathematics.asmdef | 21 + ...s.FluentAssertions.Mathematics.asmdef.meta | 7 + .../UnityAdoption/Mathematics/Extensions.meta | 8 + .../Extensions/Float3Extensions.cs | 16 + .../Extensions/Float3Extensions.cs.meta | 3 + .../Extensions/NullableFloat3Extensions.cs | 16 + .../NullableFloat3Extensions.cs.meta | 3 + .../Tests.meta | 8 + .../Tests/Editor.meta | 8 + ...udios.FluentAssertions.Editor.Tests.asmdef | 24 + ....FluentAssertions.Editor.Tests.asmdef.meta | 7 + .../Tests/Editor/Mathematics.meta | 3 + ...Assertions.Mathematics.Editor.Tests.asmdef | 27 + ...tions.Mathematics.Editor.Tests.asmdef.meta | 3 + .../Tests/Editor/Mathematics/Float3Tests.cs | 37 ++ .../Editor/Mathematics/Float3Tests.cs.meta | 3 + .../Tests/Editor/Vector3Tests.cs | 37 ++ .../Tests/Editor/Vector3Tests.cs.meta | 3 + FluentAssertions/Packages/manifest.json | 1 + FluentAssertions/Packages/packages-lock.json | 7 + .../ProjectSettings/ProjectSettings.asset | 15 +- .../UserSettings/Layouts/default-2021.dwlt | 609 +++++++++++++++--- 42 files changed, 1072 insertions(+), 114 deletions(-) create mode 100644 FluentAssertions/Assembly-CSharp.csproj.DotSettings create mode 100644 FluentAssertions/BoundfoxStudios.FluentAssertions.Editor.Tests.csproj.DotSettings create mode 100644 FluentAssertions/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.csproj.DotSettings create mode 100644 FluentAssertions/BoundfoxStudios.FluentAssertions.Mathematics.csproj.DotSettings create mode 100644 FluentAssertions/BoundfoxStudios.FluentAssertions.csproj.DotSettings create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/NullableMathematicsAssertions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/NullableMathematicsAssertions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Guard.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Guard.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/BoundfoxStudios.FluentAssertions.Editor.Tests.asmdef create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/BoundfoxStudios.FluentAssertions.Editor.Tests.asmdef.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs.meta diff --git a/FluentAssertions/Assembly-CSharp.csproj.DotSettings b/FluentAssertions/Assembly-CSharp.csproj.DotSettings new file mode 100644 index 0000000..4ba7570 --- /dev/null +++ b/FluentAssertions/Assembly-CSharp.csproj.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/FluentAssertions/BoundfoxStudios.FluentAssertions.Editor.Tests.csproj.DotSettings b/FluentAssertions/BoundfoxStudios.FluentAssertions.Editor.Tests.csproj.DotSettings new file mode 100644 index 0000000..00fae93 --- /dev/null +++ b/FluentAssertions/BoundfoxStudios.FluentAssertions.Editor.Tests.csproj.DotSettings @@ -0,0 +1,3 @@ + + True + True \ No newline at end of file diff --git a/FluentAssertions/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.csproj.DotSettings b/FluentAssertions/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.csproj.DotSettings new file mode 100644 index 0000000..baf86be --- /dev/null +++ b/FluentAssertions/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.csproj.DotSettings @@ -0,0 +1,4 @@ + + True + True + True \ No newline at end of file diff --git a/FluentAssertions/BoundfoxStudios.FluentAssertions.Mathematics.csproj.DotSettings b/FluentAssertions/BoundfoxStudios.FluentAssertions.Mathematics.csproj.DotSettings new file mode 100644 index 0000000..c3293d6 --- /dev/null +++ b/FluentAssertions/BoundfoxStudios.FluentAssertions.Mathematics.csproj.DotSettings @@ -0,0 +1,4 @@ + + True + True + True \ No newline at end of file diff --git a/FluentAssertions/BoundfoxStudios.FluentAssertions.csproj.DotSettings b/FluentAssertions/BoundfoxStudios.FluentAssertions.csproj.DotSettings new file mode 100644 index 0000000..efac06d --- /dev/null +++ b/FluentAssertions/BoundfoxStudios.FluentAssertions.csproj.DotSettings @@ -0,0 +1,4 @@ + + True + True + True \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/BoundfoxStudios.FluentAssertions.asmdef b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/BoundfoxStudios.FluentAssertions.asmdef index c087292..b145159 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/BoundfoxStudios.FluentAssertions.asmdef +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/BoundfoxStudios.FluentAssertions.asmdef @@ -1,6 +1,6 @@ { "name": "BoundfoxStudios.FluentAssertions", - "rootNamespace": "", + "rootNamespace": "BoundfoxStudios.FluentAssertions", "references": [], "includePlatforms": [], "excludePlatforms": [], @@ -11,4 +11,4 @@ "defineConstraints": [], "versionDefines": [], "noEngineReferences": false -} \ No newline at end of file +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/AppSettingsConfigurationStore.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/AppSettingsConfigurationStore.cs index 99ab4f2..a32ca41 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/AppSettingsConfigurationStore.cs +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/AppSettingsConfigurationStore.cs @@ -1,11 +1,9 @@ // ReSharper disable once CheckNamespace + namespace FluentAssertions.Common { internal class AppSettingsConfigurationStore : IConfigurationStore { - public string GetSetting(string name) - { - return ""; // TODO: This is basically the same as the NullConfigurationProvider. Let's see, if we need to wire this up in Unity somehow. - } + public string GetSetting(string name) => ""; // TODO: This is basically the same as the NullConfigurationProvider. Let's see, if we need to wire this up in Unity somehow. } } diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions.meta new file mode 100644 index 0000000..cdd54f6 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d8fb4445a3a24db6aaf43ad7182d6891 +timeCreated: 1677068801 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs new file mode 100644 index 0000000..ba5ff59 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Linq.Expressions; +using FluentAssertions; +using FluentAssertions.Execution; +using JetBrains.Annotations; + +namespace BoundfoxStudios.FluentAssertions +{ + public abstract class MathematicsAssertions : MathematicsAssertions> + where TSubject : struct, IEquatable, IFormattable + { + protected MathematicsAssertions(TSubject subject) : base(subject) { } + } + + [DebuggerNonUserCode] + public abstract class MathematicsAssertions + where TSubject : struct, IEquatable, IFormattable + where TAssertions : MathematicsAssertions + { + public MathematicsAssertions(TSubject subject) : this((TSubject?)subject) { } + + private protected MathematicsAssertions(TSubject? subject) => Subject = subject; + + /// + /// Gets the object which value is being asserted. + /// + public TSubject? Subject { get; } + + public AndConstraint Be(TSubject expected, string because = "", params object[] becauseArgs) + { + Execute.Assertion + .ForCondition(Subject?.Equals(expected) == true) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be {0}{reason}, but found {1}" + GenerateDifferenceMessage(expected), expected, Subject); + + return new((TAssertions)this); + } + + public AndConstraint Be(TSubject? expected, string because = "", params object[] becauseArgs) + { + Execute.Assertion + .ForCondition(expected is { } value ? Subject?.Equals(value) == true : !Subject.HasValue) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be {0}{reason}, but found {1}" + GenerateDifferenceMessage(expected), expected, Subject); + + return new((TAssertions)this); + } + + public AndConstraint NotBe(TSubject unexpected, string because = "", params object[] becauseArgs) + { + Execute.Assertion + .ForCondition(Subject?.Equals(unexpected) == false) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be {0}{reason}, but found {1}" + GenerateDifferenceMessage(unexpected), unexpected, Subject); + + return new((TAssertions)this); + } + + public AndConstraint NotBe(TSubject? unexpected, string because = "", params object[] becauseArgs) + { + Execute.Assertion + .ForCondition(unexpected is { } value ? Subject?.Equals(value) == false : Subject.HasValue) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be {0}{reason}, but found {1}" + GenerateDifferenceMessage(unexpected), unexpected, Subject); + + return new((TAssertions)this); + } + + public AndConstraint BeOneOf(params TSubject[] validValues) => BeOneOf(validValues, string.Empty); + + public AndConstraint BeOneOf(IEnumerable validValues, string because = "", + params object[] becauseArgs) + { + Execute.Assertion + .ForCondition(Subject is { } value && validValues.Contains(value)) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be one of {0}{reason}, but found {1}.", validValues, Subject); + + return new((TAssertions)this); + } + + public AndConstraint BeApproximately(TSubject expected, float precision, string because = "", params object[] becauseArgs) + { + Execute.Assertion + .ForCondition(Subject is { } value && CalculateApproximately(value, expected, precision)) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be {0}{reason}, but found {1}" + GenerateDifferenceMessage(expected), expected, Subject); + + return new((TAssertions)this); + } + + public AndConstraint BeOfType(Type expectedType, string because = "", params object[] becauseArgs) + { + Guard.AgainstNull(expectedType, nameof(expectedType)); + + var subjectType = Subject?.GetType(); + if (expectedType.IsGenericTypeDefinition && subjectType?.IsGenericType == true) + { + subjectType.GetGenericTypeDefinition().Should().Be(expectedType, because, becauseArgs); + } + else + { + subjectType.Should().Be(expectedType, because, becauseArgs); + } + + return new((TAssertions)this); + } + + public AndConstraint NotBeOfType(Type unexpectedType, string because = "", params object[] becauseArgs) + { + Guard.AgainstNull(unexpectedType, nameof(unexpectedType)); + + Execute.Assertion + .ForCondition(Subject.HasValue) + .BecauseOf(because, becauseArgs) + .FailWith("Expected type not to be " + unexpectedType + "{reason}, but found ."); + + Subject.GetType().Should().NotBe(unexpectedType, because, becauseArgs); + + return new((TAssertions)this); + } + + public AndConstraint Match(Expression> predicate, + string because = "", + params object[] becauseArgs) + { + Guard.AgainstNull(predicate, nameof(predicate)); + + Execute.Assertion + .ForCondition(predicate.Compile()((TSubject)Subject)) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to match {0}{reason}, but found {1}.", predicate.Body, Subject); + + return new((TAssertions)this); + } + + protected abstract bool CalculateApproximately(TSubject subject, TSubject expected, float precision); + + [CanBeNull] + private protected virtual string CalculateDifferenceForFailureMessage(TSubject subject, TSubject expected) => null; + + private string GenerateDifferenceMessage(TSubject? expected) + { + const string noDifferenceMessage = "."; + + if (Subject is not { } subject || expected is not { } expectedValue) + { + return noDifferenceMessage; + } + + var difference = CalculateDifferenceForFailureMessage(subject, expectedValue); + return difference is null ? noDifferenceMessage : $" (difference of {difference}"; + } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs.meta new file mode 100644 index 0000000..023d92e --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4cc9e0a9df954ac899e1f764f48d25b9 +timeCreated: 1677058469 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/NullableMathematicsAssertions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/NullableMathematicsAssertions.cs new file mode 100644 index 0000000..c188de0 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/NullableMathematicsAssertions.cs @@ -0,0 +1,61 @@ +using System; +using System.Diagnostics; +using System.Linq.Expressions; +using FluentAssertions; +using FluentAssertions.Execution; + +namespace BoundfoxStudios.FluentAssertions +{ + [DebuggerNonUserCode] + public abstract class NullableMathematicsAssertions : MathematicsAssertions> + where TSubject : struct, IEquatable, IFormattable + { + public NullableMathematicsAssertions(TSubject? subject) : base(subject) { } + } + + [DebuggerNonUserCode] + public abstract class NullableMathematicsAssertions : MathematicsAssertions + where TSubject : struct, IEquatable, IFormattable + where TAssertions : NullableMathematicsAssertions + { + public NullableMathematicsAssertions(TSubject? subject) : base(subject) { } + + public AndConstraint HaveValue(string because = "", params object[] becauseArgs) + { + Execute.Assertion + .ForCondition(Subject.HasValue) + .BecauseOf(because, becauseArgs) + .FailWith("Expected a value{reason}."); + + return new((TAssertions)this); + } + + public AndConstraint NotBeNull(string because = "", params object[] becauseArgs) => HaveValue(because, becauseArgs); + + public AndConstraint NotHaveValue(string because = "", params object[] becauseArgs) + { + Execute.Assertion + .ForCondition(!Subject.HasValue) + .BecauseOf(because, becauseArgs) + .FailWith("Did not expect a value{reason}, but found {0}.", Subject); + + return new((TAssertions)this); + } + + public AndConstraint BeNull(string because = "", params object[] becauseArgs) => NotHaveValue(because, becauseArgs); + + public AndConstraint Match(Expression> predicate, + string because = "", + params object[] becauseArgs) + { + Guard.AgainstNull(predicate, nameof(predicate)); + + Execute.Assertion + .ForCondition(predicate.Compile()(Subject)) + .BecauseOf(because, becauseArgs) + .FailWith("Expected value to match {0}{reason}, but found {1}.", predicate, Subject); + + return new((TAssertions)this); + } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/NullableMathematicsAssertions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/NullableMathematicsAssertions.cs.meta new file mode 100644 index 0000000..dbadabc --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/NullableMathematicsAssertions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7b53ef0d12a649aca5a275cfd2eab3e3 +timeCreated: 1677066592 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions.meta new file mode 100644 index 0000000..5e2687e --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5fd03d78190c4588bc998e02b1dd6b54 +timeCreated: 1677068553 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs new file mode 100644 index 0000000..a10d084 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs @@ -0,0 +1,15 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class NullableVector3Extensions + { + public static NullableVector3Assertions Should(this Vector3? instance) => new(instance); + } + + public class NullableVector3Assertions : NullableMathematicsAssertions + { + public NullableVector3Assertions(Vector3? subject) : base(subject) { } + protected override bool CalculateApproximately(Vector3 subject, Vector3 expected, float precision) => (subject - expected).sqrMagnitude < precision; + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs.meta new file mode 100644 index 0000000..5345724 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: dc359823660a4085951f5a9d27d0d353 +timeCreated: 1677068927 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs new file mode 100644 index 0000000..7ecf996 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs @@ -0,0 +1,15 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class Vector3Extensions + { + public static Vector3Assertions Should(this Vector3 instance) => new(instance); + } + + public class Vector3Assertions : MathematicsAssertions + { + public Vector3Assertions(Vector3 subject) : base(subject) { } + protected override bool CalculateApproximately(Vector3 subject, Vector3 expected, float precision) => (subject - expected).sqrMagnitude < precision; + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs.meta new file mode 100644 index 0000000..a9b3fb3 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 543b86d7339948c885a0c2f67a931a7e +timeCreated: 1677068580 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Guard.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Guard.cs new file mode 100644 index 0000000..c71829e --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Guard.cs @@ -0,0 +1,15 @@ +using System; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class Guard + { + public static void AgainstNull(T obj, string paramName) + { + if (obj is null) + { + throw new ArgumentNullException(paramName); + } + } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Guard.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Guard.cs.meta new file mode 100644 index 0000000..d8560b7 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Guard.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e04909514ed94877a3bd490633676d54 +timeCreated: 1677062950 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics.meta new file mode 100644 index 0000000..430b5eb --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8b8d4c46ab9c746b6b6c9a28c31546ce +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef new file mode 100644 index 0000000..7450f4a --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef @@ -0,0 +1,21 @@ +{ + "name": "BoundfoxStudios.FluentAssertions.Mathematics", + "rootNamespace": "BoundfoxStudios.FluentAssertions.Mathematics", + "references": [ + "GUID:d8b63aba1907145bea998dd612889d6b", + "GUID:e372c541aba5148868e12aa078ca7c20" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [ + "FLUENTASSERTIONS_UNITY_MATHEMATICS" + ], + "versionDefines": [], + "noEngineReferences": false +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef.meta new file mode 100644 index 0000000..51b79f6 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7481bc82716e140f2bf8f8991a7b718f +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions.meta new file mode 100644 index 0000000..90753ad --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8e82da8e5c48f44329354ae767aa41f1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs new file mode 100644 index 0000000..461dbfb --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs @@ -0,0 +1,16 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class Float3Extensions + { + public static Float3Assertions Should(this float3 instance) => new(instance); + } + + public class Float3Assertions : MathematicsAssertions + { + public Float3Assertions(float3 subject) : base(subject) { } + + protected override bool CalculateApproximately(float3 subject, float3 expected, float precision) => math.lengthsq(subject - expected) < precision; + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs.meta new file mode 100644 index 0000000..a9ec5ac --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 66bbb951979f4c628954e21016125a08 +timeCreated: 1677057637 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs new file mode 100644 index 0000000..87fceba --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs @@ -0,0 +1,16 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class NullableFloat3Extensions + { + public static NullableFloat3Assertions Should(this float3? instance) => new(instance); + } + + public class NullableFloat3Assertions : NullableMathematicsAssertions + { + public NullableFloat3Assertions(float3? subject) : base(subject) { } + + protected override bool CalculateApproximately(float3 subject, float3 expected, float precision) => math.lengthsq(subject - expected) < precision; + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs.meta new file mode 100644 index 0000000..ce913c9 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5a4d8df228bc4e538138df241067ac37 +timeCreated: 1677068099 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests.meta new file mode 100644 index 0000000..7b75242 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ffcc0c51e4507415f81f318f66647aa9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor.meta new file mode 100644 index 0000000..c5bd4c2 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 15f9c5b61f2184a8ba785cf2d5a81640 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/BoundfoxStudios.FluentAssertions.Editor.Tests.asmdef b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/BoundfoxStudios.FluentAssertions.Editor.Tests.asmdef new file mode 100644 index 0000000..e5af5fb --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/BoundfoxStudios.FluentAssertions.Editor.Tests.asmdef @@ -0,0 +1,24 @@ +{ + "name": "BoundfoxStudios.FluentAssertions.Editor.Tests", + "rootNamespace": "BoundfoxStudios.FluentAssertions.Editor.Tests", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner", + "BoundfoxStudios.FluentAssertions" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/BoundfoxStudios.FluentAssertions.Editor.Tests.asmdef.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/BoundfoxStudios.FluentAssertions.Editor.Tests.asmdef.meta new file mode 100644 index 0000000..4361751 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/BoundfoxStudios.FluentAssertions.Editor.Tests.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1850269c2d06a477492a4ac647f74c2c +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics.meta new file mode 100644 index 0000000..fd3caf9 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 00249639e7f142cfaee152102df1fdae +timeCreated: 1677058130 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef new file mode 100644 index 0000000..878199e --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef @@ -0,0 +1,27 @@ +{ + "name": "BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests", + "rootNamespace": "BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner", + "BoundfoxStudios.FluentAssertions", + "BoundfoxStudios.FluentAssertions.Mathematics", + "Unity.Mathematics" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS", + "FLUENTASSERTIONS_UNITY_MATHEMATICS" + ], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef.meta new file mode 100644 index 0000000..7803b83 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8dddd9b03f7c4f59adbe56c5f7bfbe9d +timeCreated: 1677058134 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs new file mode 100644 index 0000000..32abbd3 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs @@ -0,0 +1,37 @@ +using NUnit.Framework; +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests +{ + public class Float3Tests + { + [Test] + public void Float3BePasses() + { + var v1 = new float3(1, 2, 3); + var expected = new float3(1, 2, 3); + + v1.Should().Be(expected); + } + + [Test] + public void Float3BeShouldMatchExactly() + { + var v1 = new float3(2, 4, 6); + var expected = new float3(0.267261237f, 0.534522474f, 0.801783681f); + + var normalized = math.normalize(v1); + normalized.Should().Be(expected); + } + + [Test] + public void Float3BeApproximatelyPasses() + { + var v1 = new float3(2, 4, 6); + var expected = new float3(0.2672612f, 0.5345225f, 0.8017837f); + + var normalized = math.normalize(v1); + normalized.Should().BeApproximately(expected, 0.5f); + } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs.meta new file mode 100644 index 0000000..9f83a63 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 75bd39e102654b29897a6d314b6b95f8 +timeCreated: 1677058235 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs new file mode 100644 index 0000000..09d73b5 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs @@ -0,0 +1,37 @@ +using NUnit.Framework; +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions.Editor.Tests +{ + public class Vector3Tests + { + [Test] + public void Vector3BePasses() + { + var v1 = new Vector3(1, 2, 3); + var expected = new Vector3(1, 2, 3); + + v1.Should().Be(expected); + } + + [Test] + public void Vector3BeShouldMatchExactly() + { + var v1 = new Vector3(2, 4, 6); + var expected = new Vector3(0.267261237f, 0.534522474f, 0.801783681f); + + var normalized = v1.normalized; + normalized.Should().Be(expected); + } + + [Test] + public void Vector3BeApproximatelyPasses() + { + var v1 = new Vector3(2, 4, 6); + var expected = new Vector3(0.2672612f, 0.5345225f, 0.8017837f); + + var normalized = v1.normalized; + normalized.Should().BeApproximately(expected, 0.5f); + } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs.meta new file mode 100644 index 0000000..6d4b9be --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d05c4e32ce074be097477cfa6aec7825 +timeCreated: 1677068955 \ No newline at end of file diff --git a/FluentAssertions/Packages/manifest.json b/FluentAssertions/Packages/manifest.json index 349ad45..ee4cf67 100644 --- a/FluentAssertions/Packages/manifest.json +++ b/FluentAssertions/Packages/manifest.json @@ -9,6 +9,7 @@ "com.unity.ide.rider": "3.0.18", "com.unity.ide.visualstudio": "2.0.17", "com.unity.ide.vscode": "1.2.5", + "com.unity.mathematics": "1.2.6", "com.unity.test-framework": "1.3.2", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.6.4", diff --git a/FluentAssertions/Packages/packages-lock.json b/FluentAssertions/Packages/packages-lock.json index 2ac42e5..c3c9f50 100644 --- a/FluentAssertions/Packages/packages-lock.json +++ b/FluentAssertions/Packages/packages-lock.json @@ -75,6 +75,13 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.mathematics": { + "version": "1.2.6", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.nuget.mono-cecil": { "version": "1.10.1", "depth": 2, diff --git a/FluentAssertions/ProjectSettings/ProjectSettings.asset b/FluentAssertions/ProjectSettings/ProjectSettings.asset index 1bb1673..ab0e41d 100644 --- a/FluentAssertions/ProjectSettings/ProjectSettings.asset +++ b/FluentAssertions/ProjectSettings/ProjectSettings.asset @@ -145,14 +145,17 @@ PlayerSettings: enable360StereoCapture: 0 isWsaHolographicRemotingEnabled: 0 enableFrameTimingStats: 0 + enableOpenGLProfilerGPURecorders: 1 useHDRDisplay: 0 D3DHDRBitDepth: 0 m_ColorGamuts: 0000000003000000 targetPixelDensity: 30 resolutionScalingMode: 0 + resetResolutionOnWindowResize: 0 androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 - applicationIdentifier: {} + applicationIdentifier: + Standalone: com.DefaultCompany.FluentAssertions buildNumber: Standalone: 0 iPhone: 0 @@ -473,6 +476,7 @@ PlayerSettings: - m_BuildTarget: WebGL m_StaticBatching: 0 m_DynamicBatching: 0 + m_BuildTargetShaderSettings: [] m_BuildTargetGraphicsJobs: - m_BuildTarget: MacStandaloneSupport m_GraphicsJobs: 0 @@ -521,6 +525,8 @@ PlayerSettings: m_APIs: 0b000000 m_Automatic: 0 m_BuildTargetVRSettings: [] + m_DefaultShaderChunkSizeInMB: 16 + m_DefaultShaderChunkCount: 0 openGLRequireES31: 0 openGLRequireES31AEP: 0 openGLRequireES32: 0 @@ -683,6 +689,7 @@ PlayerSettings: switchNetworkInterfaceManagerInitializeEnabled: 1 switchPlayerConnectionEnabled: 1 switchUseNewStyleFilepaths: 0 + switchUseLegacyFmodPriorities: 1 switchUseMicroSleepForYield: 1 switchEnableRamDiskSupport: 0 switchMicroSleepForYieldTime: 25 @@ -757,6 +764,7 @@ PlayerSettings: ps4videoRecordingFeaturesUsed: 0 ps4contentSearchFeaturesUsed: 0 ps4CompatibilityPS5: 0 + ps4AllowPS5Detection: 0 ps4GPU800MHz: 1 ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] @@ -781,6 +789,7 @@ PlayerSettings: webGLLinkerTarget: 1 webGLThreadsSupport: 0 webGLDecompressionFallback: 0 + webGLPowerPreference: 2 scriptingDefineSymbols: : UNITY_POST_PROCESSING_STACK_V2 Android: UNITY_POST_PROCESSING_STACK_V2 @@ -789,7 +798,7 @@ PlayerSettings: Nintendo Switch: UNITY_POST_PROCESSING_STACK_V2 PS4: UNITY_POST_PROCESSING_STACK_V2 Stadia: UNITY_POST_PROCESSING_STACK_V2 - Standalone: UNITY_POST_PROCESSING_STACK_V2;NETSTANDARD2_0 + Standalone: UNITY_POST_PROCESSING_STACK_V2;NETSTANDARD2_0;FLUENTASSERTIONS_UNITY_MATHEMATICS WebGL: UNITY_POST_PROCESSING_STACK_V2 Windows Store Apps: UNITY_POST_PROCESSING_STACK_V2 XboxOne: UNITY_POST_PROCESSING_STACK_V2 @@ -805,6 +814,7 @@ PlayerSettings: allowUnsafeCode: 0 useDeterministicCompilation: 1 enableRoslynAnalyzers: 1 + selectedPlatform: 0 additionalIl2CppArgs: scriptingRuntimeVersion: 1 gcIncremental: 0 @@ -884,6 +894,7 @@ PlayerSettings: m_VersionName: apiCompatibilityLevel: 6 activeInputHandler: 0 + windowsGamepadBackendHint: 0 cloudProjectId: framebufferDepthMemorylessMode: 0 qualitySettingsNames: [] diff --git a/FluentAssertions/UserSettings/Layouts/default-2021.dwlt b/FluentAssertions/UserSettings/Layouts/default-2021.dwlt index 66959f6..298a8e0 100644 --- a/FluentAssertions/UserSettings/Layouts/default-2021.dwlt +++ b/FluentAssertions/UserSettings/Layouts/default-2021.dwlt @@ -1,30 +1,6 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: --- !u!114 &1 -MonoBehaviour: - m_ObjectHideFlags: 52 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 12004, guid: 0000000000000000e000000000000000, type: 0} - m_Name: - m_EditorClassIdentifier: - m_PixelRect: - serializedVersion: 2 - x: 419 - y: 80 - width: 1295 - height: 772 - m_ShowMode: 0 - m_Title: Package Manager - m_RootView: {fileID: 4} - m_MinSize: {x: 800, y: 271} - m_MaxSize: {x: 4000, y: 4021} - m_Maximized: 0 ---- !u!114 &2 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -43,12 +19,12 @@ MonoBehaviour: width: 2560 height: 1387 m_ShowMode: 4 - m_Title: Inspector - m_RootView: {fileID: 9} + m_Title: Project + m_RootView: {fileID: 8} m_MinSize: {x: 875, y: 300} m_MaxSize: {x: 10000, y: 10000} m_Maximized: 1 ---- !u!114 &3 +--- !u!114 &2 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -58,23 +34,23 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0} - m_Name: PackageManagerWindow + m_Name: TestRunnerWindow m_EditorClassIdentifier: m_Children: [] m_Position: serializedVersion: 2 x: 0 y: 0 - width: 1295 - height: 772 - m_MinSize: {x: 800, y: 271} - m_MaxSize: {x: 4000, y: 4021} - m_ActualView: {fileID: 15} + width: 604 + height: 605 + m_MinSize: {x: 101, y: 121} + m_MaxSize: {x: 4001, y: 4021} + m_ActualView: {fileID: 14} m_Panes: - - {fileID: 15} + - {fileID: 14} m_Selected: 0 m_LastSelected: 0 ---- !u!114 &4 +--- !u!114 &3 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -87,18 +63,19 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Children: - - {fileID: 3} + - {fileID: 2} + - {fileID: 5} m_Position: serializedVersion: 2 - x: 0 + x: 1956 y: 0 - width: 1295 - height: 772 - m_MinSize: {x: 800, y: 271} - m_MaxSize: {x: 4000, y: 4021} - vertical: 0 - controlID: 849 ---- !u!114 &5 + width: 604 + height: 1337 + m_MinSize: {x: 100, y: 200} + m_MaxSize: {x: 8096, y: 16192} + vertical: 1 + controlID: 45 +--- !u!114 &4 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -111,8 +88,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Children: - - {fileID: 12} - - {fileID: 6} + - {fileID: 11} + - {fileID: 3} m_Position: serializedVersion: 2 x: 0 @@ -122,8 +99,8 @@ MonoBehaviour: m_MinSize: {x: 300, y: 200} m_MaxSize: {x: 24288, y: 16192} vertical: 0 - controlID: 99 ---- !u!114 &6 + controlID: 85 +--- !u!114 &5 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -138,18 +115,18 @@ MonoBehaviour: m_Children: [] m_Position: serializedVersion: 2 - x: 1956 - y: 0 + x: 0 + y: 605 width: 604 - height: 1337 + height: 732 m_MinSize: {x: 276, y: 71} m_MaxSize: {x: 4001, y: 4021} - m_ActualView: {fileID: 17} + m_ActualView: {fileID: 16} m_Panes: - - {fileID: 17} + - {fileID: 16} m_Selected: 0 m_LastSelected: 0 ---- !u!114 &7 +--- !u!114 &6 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -168,14 +145,14 @@ MonoBehaviour: y: 0 width: 485 height: 792 - m_MinSize: {x: 201, y: 221} - m_MaxSize: {x: 4001, y: 4021} - m_ActualView: {fileID: 18} + m_MinSize: {x: 200, y: 200} + m_MaxSize: {x: 4000, y: 4000} + m_ActualView: {fileID: 17} m_Panes: - - {fileID: 18} + - {fileID: 17} m_Selected: 0 m_LastSelected: 0 ---- !u!114 &8 +--- !u!114 &7 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -196,13 +173,13 @@ MonoBehaviour: height: 545 m_MinSize: {x: 231, y: 271} m_MaxSize: {x: 10001, y: 10021} - m_ActualView: {fileID: 16} + m_ActualView: {fileID: 15} m_Panes: - - {fileID: 16} - - {fileID: 21} + - {fileID: 15} + - {fileID: 20} m_Selected: 0 m_LastSelected: 1 ---- !u!114 &9 +--- !u!114 &8 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -215,9 +192,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Children: + - {fileID: 9} + - {fileID: 4} - {fileID: 10} - - {fileID: 5} - - {fileID: 11} m_Position: serializedVersion: 2 x: 0 @@ -230,7 +207,7 @@ MonoBehaviour: m_TopViewHeight: 30 m_UseBottomView: 1 m_BottomViewHeight: 20 ---- !u!114 &10 +--- !u!114 &9 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -252,7 +229,7 @@ MonoBehaviour: m_MinSize: {x: 0, y: 0} m_MaxSize: {x: 0, y: 0} m_LastLoadedLayoutName: ---- !u!114 &11 +--- !u!114 &10 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -273,7 +250,7 @@ MonoBehaviour: height: 20 m_MinSize: {x: 0, y: 0} m_MaxSize: {x: 0, y: 0} ---- !u!114 &12 +--- !u!114 &11 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -286,8 +263,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Children: - - {fileID: 13} - - {fileID: 8} + - {fileID: 12} + - {fileID: 7} m_Position: serializedVersion: 2 x: 0 @@ -297,8 +274,8 @@ MonoBehaviour: m_MinSize: {x: 200, y: 200} m_MaxSize: {x: 16192, y: 16192} vertical: 1 - controlID: 100 ---- !u!114 &13 + controlID: 86 +--- !u!114 &12 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -311,8 +288,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Children: - - {fileID: 7} - - {fileID: 14} + - {fileID: 6} + - {fileID: 13} m_Position: serializedVersion: 2 x: 0 @@ -322,8 +299,8 @@ MonoBehaviour: m_MinSize: {x: 200, y: 100} m_MaxSize: {x: 16192, y: 8096} vertical: 0 - controlID: 81 ---- !u!114 &14 + controlID: 73 +--- !u!114 &13 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -344,13 +321,13 @@ MonoBehaviour: height: 792 m_MinSize: {x: 202, y: 221} m_MaxSize: {x: 4002, y: 4021} - m_ActualView: {fileID: 19} + m_ActualView: {fileID: 18} m_Panes: + - {fileID: 18} - {fileID: 19} - - {fileID: 20} m_Selected: 0 m_LastSelected: 1 ---- !u!114 &15 +--- !u!114 &14 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -359,27 +336,447 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 13953, guid: 0000000000000000e000000000000000, type: 0} + m_Script: {fileID: 13401, guid: 0000000000000000e000000000000000, type: 0} m_Name: m_EditorClassIdentifier: - m_MinSize: {x: 800, y: 250} + m_MinSize: {x: 100, y: 100} m_MaxSize: {x: 4000, y: 4000} m_TitleContent: - m_Text: Package Manager - m_Image: {fileID: -2824328813065806953, guid: 0000000000000000d000000000000000, - type: 0} + m_Text: Test Runner + m_Image: {fileID: 0} m_Tooltip: m_Pos: serializedVersion: 2 - x: 419 - y: 80 - width: 1295 - height: 751 + x: 1956 + y: 83 + width: 603 + height: 584 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default m_SaveData: [] ---- !u!114 &16 + m_Spl: + ID: 152 + splitterInitialOffset: 0 + currentActiveSplitter: -1 + realSizes: + - 385 + - 129 + relativeSizes: + - 0.75 + - 0.25 + minSizes: + - 32 + - 32 + maxSizes: + - 0 + - 0 + lastTotalSize: 514 + splitSize: 6 + xOffset: 0 + m_Version: 1 + oldRealSizes: + oldMinSizes: + oldMaxSizes: + oldSplitSize: 0 + m_TestTypeToolbarIndex: 1 + m_PlayModeTestListGUI: + m_Window: {fileID: 0} + m_NewResultList: [] + m_ResultText: + m_ResultStacktrace: + m_TestListState: + scrollPos: {x: 0, y: 0} + m_SelectedIDs: + m_LastClickedID: 0 + m_ExpandedIDs: + m_RenameOverlay: + m_UserAcceptedRename: 0 + m_Name: + m_OriginalName: + m_EditFieldRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 0 + height: 0 + m_UserData: 0 + m_IsWaitingForDelay: 0 + m_IsRenaming: 0 + m_OriginalEventType: 11 + m_IsRenamingFilename: 0 + m_ClientGUIView: {fileID: 0} + m_SearchString: + m_TestRunnerUIFilter: + PassedHidden: 0 + FailedHidden: 0 + NotRunHidden: 0 + m_SearchString: + selectedCategoryMask: 0 + availableCategories: [] + m_SelectedOption: 0 + m_EditModeTestListGUI: + m_Window: {fileID: 14} + m_NewResultList: + - id: 1000 + uniqueId: '[FluentAssertions][suite]' + name: FluentAssertions + fullName: FluentAssertions + resultStatus: 1 + duration: 0.0889035 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: + parentUniqueId: + - id: 1005 + uniqueId: '[BoundfoxStudios.FluentAssertions.Editor.Tests.dll][suite]' + name: BoundfoxStudios.FluentAssertions.Editor.Tests.dll + fullName: /Users/manuelrauber/projects/private/fluentassertions-unity/FluentAssertions/Library/ScriptAssemblies/BoundfoxStudios.FluentAssertions.Editor.Tests.dll + resultStatus: 1 + duration: 0.0346214 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1000 + parentUniqueId: '[FluentAssertions][suite]' + - id: 1006 + uniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/[BoundfoxStudios][suite] + name: BoundfoxStudios + fullName: BoundfoxStudios + resultStatus: 1 + duration: 0.0329668 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1005 + parentUniqueId: '[BoundfoxStudios.FluentAssertions.Editor.Tests.dll][suite]' + - id: 1007 + uniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/[FluentAssertions][suite] + name: FluentAssertions + fullName: BoundfoxStudios.FluentAssertions + resultStatus: 1 + duration: 0.0292481 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1006 + parentUniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/[BoundfoxStudios][suite] + - id: 1008 + uniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/[Editor][suite] + name: Editor + fullName: BoundfoxStudios.FluentAssertions.Editor + resultStatus: 1 + duration: 0.0255845 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1007 + parentUniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/[FluentAssertions][suite] + - id: 1009 + uniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Editor/[BoundfoxStudios.FluentAssertions.Editor.Tests][BoundfoxStudios.FluentAssertions.Editor.Tests][suite] + name: Tests + fullName: BoundfoxStudios.FluentAssertions.Editor.Tests + resultStatus: 1 + duration: 0.0218555 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1008 + parentUniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/[Editor][suite] + - id: 1001 + uniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Editor/Tests/[BoundfoxStudios.FluentAssertions.Editor.Tests][BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests][suite] + name: Vector3Tests + fullName: BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests + resultStatus: 1 + duration: 0.017596 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1009 + parentUniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Editor/[BoundfoxStudios.FluentAssertions.Editor.Tests][BoundfoxStudios.FluentAssertions.Editor.Tests][suite] + - id: 1004 + uniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Editor/Tests/Vector3Tests/[BoundfoxStudios.FluentAssertions.Editor.Tests][BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests.Vector3BeApproximatelyPasses] + name: Vector3BeApproximatelyPasses + fullName: BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests.Vector3BeApproximatelyPasses + resultStatus: 1 + duration: 0.009028 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 0 + categories: + - Uncategorized + parentId: 1001 + parentUniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Editor/Tests/[BoundfoxStudios.FluentAssertions.Editor.Tests][BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests][suite] + - id: 1002 + uniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Editor/Tests/Vector3Tests/[BoundfoxStudios.FluentAssertions.Editor.Tests][BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests.Vector3BePasses] + name: Vector3BePasses + fullName: BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests.Vector3BePasses + resultStatus: 1 + duration: 0.0003258 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 0 + categories: + - Uncategorized + parentId: 1001 + parentUniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Editor/Tests/[BoundfoxStudios.FluentAssertions.Editor.Tests][BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests][suite] + - id: 1003 + uniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Editor/Tests/Vector3Tests/[BoundfoxStudios.FluentAssertions.Editor.Tests][BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests.Vector3BeShouldMatchExactly] + name: Vector3BeShouldMatchExactly + fullName: BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests.Vector3BeShouldMatchExactly + resultStatus: 1 + duration: 0.0001149 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 0 + categories: + - Uncategorized + parentId: 1001 + parentUniqueId: BoundfoxStudios.FluentAssertions.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Editor/Tests/[BoundfoxStudios.FluentAssertions.Editor.Tests][BoundfoxStudios.FluentAssertions.Editor.Tests.Vector3Tests][suite] + - id: 1003 + uniqueId: '[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll][suite]' + name: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll + fullName: /Users/manuelrauber/projects/private/fluentassertions-unity/FluentAssertions/Library/ScriptAssemblies/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll + resultStatus: 1 + duration: 0.0282036 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1000 + parentUniqueId: '[FluentAssertions][suite]' + - id: 1004 + uniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/[BoundfoxStudios][suite] + name: BoundfoxStudios + fullName: BoundfoxStudios + resultStatus: 1 + duration: 0.0245454 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1003 + parentUniqueId: '[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll][suite]' + - id: 1005 + uniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/[FluentAssertions][suite] + name: FluentAssertions + fullName: BoundfoxStudios.FluentAssertions + resultStatus: 1 + duration: 0.0207364 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1004 + parentUniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/[BoundfoxStudios][suite] + - id: 1006 + uniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/[Mathematics][suite] + name: Mathematics + fullName: BoundfoxStudios.FluentAssertions.Mathematics + resultStatus: 1 + duration: 0.0170266 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1005 + parentUniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/[FluentAssertions][suite] + - id: 1007 + uniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/[Editor][suite] + name: Editor + fullName: BoundfoxStudios.FluentAssertions.Mathematics.Editor + resultStatus: 1 + duration: 0.0136636 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1006 + parentUniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/[Mathematics][suite] + - id: 1008 + uniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/Editor/[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][suite] + name: Tests + fullName: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests + resultStatus: 1 + duration: 0.0098416 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1007 + parentUniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/[Editor][suite] + - id: 1001 + uniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/Editor/Tests/[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests][suite] + name: Float3Tests + fullName: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests + resultStatus: 1 + duration: 0.0060706 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 1 + categories: [] + parentId: 1008 + parentUniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/Editor/[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][suite] + - id: 1004 + uniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/Editor/Tests/Float3Tests/[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests.Float3BeApproximatelyPasses] + name: Float3BeApproximatelyPasses + fullName: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests.Float3BeApproximatelyPasses + resultStatus: 1 + duration: 0.0012157 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 0 + categories: + - Uncategorized + parentId: 1001 + parentUniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/Editor/Tests/[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests][suite] + - id: 1002 + uniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/Editor/Tests/Float3Tests/[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests.Float3BePasses] + name: Float3BePasses + fullName: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests.Float3BePasses + resultStatus: 1 + duration: 0.0002909 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 0 + categories: + - Uncategorized + parentId: 1001 + parentUniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/Editor/Tests/[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests][suite] + - id: 1003 + uniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/Editor/Tests/Float3Tests/[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests.Float3BeShouldMatchExactly] + name: Float3BeShouldMatchExactly + fullName: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests.Float3BeShouldMatchExactly + resultStatus: 1 + duration: 0.0000954 + messages: + output: + stacktrace: + notRunnable: 0 + ignoredOrSkipped: 0 + description: + isSuite: 0 + categories: + - Uncategorized + parentId: 1001 + parentUniqueId: BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.dll/BoundfoxStudios/FluentAssertions/Mathematics/Editor/Tests/[BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests][BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.Float3Tests][suite] + m_ResultText: BoundfoxStudios (0.033s) + m_ResultStacktrace: + m_TestListState: + scrollPos: {x: 0, y: 0} + m_SelectedIDs: 4c3298de + m_LastClickedID: -560450996 + m_ExpandedIDs: 084e7e843fc955892a5611ac2b910add4c3298dee557abf717f9760b11dfb410be756c398359db417af857423af8ff7bffffff7f + m_RenameOverlay: + m_UserAcceptedRename: 0 + m_Name: + m_OriginalName: + m_EditFieldRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 0 + height: 0 + m_UserData: 0 + m_IsWaitingForDelay: 0 + m_IsRenaming: 0 + m_OriginalEventType: 11 + m_IsRenamingFilename: 0 + m_ClientGUIView: {fileID: 0} + m_SearchString: + m_TestRunnerUIFilter: + PassedHidden: 0 + FailedHidden: 0 + NotRunHidden: 0 + m_SearchString: + selectedCategoryMask: 0 + availableCategories: + - Uncategorized +--- !u!114 &15 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -421,22 +818,22 @@ MonoBehaviour: m_SkipHidden: 0 m_SearchArea: 1 m_Folders: - - Packages/com.boundfoxstudios.fluentassertions/Runtime + - Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics m_Globs: [] m_OriginalText: m_ViewMode: 1 m_StartGridSize: 64 m_LastFolders: - - Packages/com.boundfoxstudios.fluentassertions/Runtime/Externals/UniTask + - Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics m_LastFoldersGridSize: -1 m_LastProjectPath: /Users/manuelrauber/projects/private/fluentassertions-unity/FluentAssertions m_LockTracker: m_IsLocked: 0 m_FolderTreeState: - scrollPos: {x: 0, y: 0} - m_SelectedIDs: 1c5a0000 - m_LastClickedID: 23068 - m_ExpandedIDs: 00000000185a00001a5a00001c5a0000785a000000ca9a3bffffff7f + scrollPos: {x: 0, y: 204} + m_SelectedIDs: ec530000 + m_LastClickedID: 21484 + m_ExpandedIDs: 0000000006500000085000000a5000000c5000000e500000105000005e5000006050000000ca9a3bffffff7f m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -452,7 +849,7 @@ MonoBehaviour: m_IsRenaming: 0 m_OriginalEventType: 11 m_IsRenamingFilename: 1 - m_ClientGUIView: {fileID: 0} + m_ClientGUIView: {fileID: 7} m_SearchString: m_CreateAssetUtility: m_EndAction: {fileID: 0} @@ -464,7 +861,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 00000000185a00001a5a00001c5a0000 + m_ExpandedIDs: 0000000006500000085000000a5000000c5000000e50000010500000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -520,7 +917,7 @@ MonoBehaviour: m_GridSize: 64 m_SkipHiddenPackages: 0 m_DirectoriesAreaWidth: 207 ---- !u!114 &17 +--- !u!114 &16 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -542,9 +939,9 @@ MonoBehaviour: m_Pos: serializedVersion: 2 x: 1956 - y: 83 + y: 688 width: 603 - height: 1316 + height: 711 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -562,7 +959,7 @@ MonoBehaviour: m_LockTracker: m_IsLocked: 0 m_PreviewWindow: {fileID: 0} ---- !u!114 &18 +--- !u!114 &17 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -596,7 +993,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: daf1ffff + m_ExpandedIDs: 34d0ffffb6d0ffff78d9ffffe6d9fffff0daffff58dbffff6cdcffffccdcffff2eddffff92ddffffa2deffff10dfffff32e0ffffa0e0ffffbae1ffff1ae2fffffce2ffff6ae3ffff50e4ffffbce4ffff9ce5ffff00e6ffff56e6ffffbae6ffff14e7ffff78e7ffff8ae8ffffeee8ffff8eeaffffeeeaffff40ebffffa0ebffffa6ecffff08edffff30fbffff m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -620,7 +1017,7 @@ MonoBehaviour: m_IsLocked: 0 m_CurrentSortingName: TransformSorting m_WindowGUID: 4c969a2b90040154d917609493e03593 ---- !u!114 &19 +--- !u!114 &18 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -904,7 +1301,7 @@ MonoBehaviour: m_Value: 1 m_Color: {r: 0.5, g: 0.5, b: 0.5, a: 0.4} m_Pivot: {x: 0, y: 0, z: 0} - m_Size: {x: 1, y: 1} + m_Size: {x: 0.5, y: 0.5} zGrid: m_Fade: m_Target: 0 @@ -948,7 +1345,7 @@ MonoBehaviour: m_SceneVisActive: 1 m_LastLockedObject: {fileID: 0} m_ViewIsLockedToObject: 0 ---- !u!114 &20 +--- !u!114 &19 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} @@ -1041,7 +1438,7 @@ MonoBehaviour: m_LowResolutionForAspectRatios: 01000000000000000000 m_XRRenderMode: 0 m_RenderTexture: {fileID: 0} ---- !u!114 &21 +--- !u!114 &20 MonoBehaviour: m_ObjectHideFlags: 52 m_CorrespondingSourceObject: {fileID: 0} From 223179b606dd9742037ee7cca4eacc35e35a7038 Mon Sep 17 00:00:00 2001 From: Manuel Rauber Date: Mon, 27 Feb 2023 22:24:05 +0100 Subject: [PATCH 3/3] feat: more types for the unity integration --- .../BoundfoxStudios.FluentAssertions.asmdef | 2 +- .../Assertions/MathematicsAssertions.cs | 12 - .../Extensions/BeCloseToExtensions.cs | 631 +++++++++++++++ .../Extensions/BeCloseToExtensions.cs.meta | 3 + .../Extensions/NullableVector2Extensions.cs | 14 + .../NullableVector2Extensions.cs.meta | 3 + .../NullableVector2IntExtensions.cs | 14 + .../NullableVector2IntExtensions.cs.meta | 3 + .../Extensions/NullableVector3Extensions.cs | 1 - .../NullableVector3IntExtensions.cs | 14 + .../NullableVector3IntExtensions.cs.meta | 3 + .../Extensions/NullableVector4Extensions.cs | 14 + .../NullableVector4Extensions.cs.meta | 3 + .../Extensions/Vector2Extensions.cs | 14 + .../Extensions/Vector2Extensions.cs.meta | 3 + .../Extensions/Vector2IntExtensions.cs | 14 + .../Extensions/Vector2IntExtensions.cs.meta | 3 + .../Extensions/Vector3Extensions.cs | 1 - .../Extensions/Vector3IntExtensions.cs | 14 + .../Extensions/Vector3IntExtensions.cs.meta | 3 + .../Extensions/Vector4Extensions.cs | 14 + .../Extensions/Vector4Extensions.cs.meta | 3 + ...tudios.FluentAssertions.Mathematics.asmdef | 46 +- .../Extensions/BeCloseToExtensions.cs | 753 ++++++++++++++++++ .../Extensions/BeCloseToExtensions.cs.meta | 3 + .../Extensions/Float2Extensions.cs | 14 + .../Extensions/Float2Extensions.cs.meta | 3 + .../Extensions/Float3Extensions.cs | 2 - .../Extensions/Float4Extensions.cs | 14 + .../Extensions/Float4Extensions.cs.meta | 3 + .../Mathematics/Extensions/Int2Extensions.cs | 14 + .../Extensions/Int2Extensions.cs.meta | 3 + .../Mathematics/Extensions/Int3Extensions.cs | 14 + .../Extensions/Int3Extensions.cs.meta | 3 + .../Mathematics/Extensions/Int4Extensions.cs | 14 + .../Extensions/Int4Extensions.cs.meta | 3 + .../Extensions/NullableFloat2Extensions.cs | 14 + .../NullableFloat2Extensions.cs.meta | 3 + .../Extensions/NullableFloat3Extensions.cs | 2 - .../Extensions/NullableFloat4Extensions.cs | 14 + .../NullableFloat4Extensions.cs.meta | 3 + .../Extensions/NullableInt2Extensions.cs | 14 + .../Extensions/NullableInt2Extensions.cs.meta | 3 + .../Extensions/NullableInt3Extensions.cs | 14 + .../Extensions/NullableInt3Extensions.cs.meta | 3 + .../Extensions/NullableInt4Extensions.cs | 14 + .../Extensions/NullableInt4Extensions.cs.meta | 3 + ...Assertions.Mathematics.Editor.Tests.asmdef | 8 +- ...tions.Mathematics.Editor.Tests.asmdef.meta | 6 +- .../Tests/Editor/Mathematics/Float3Tests.cs | 3 +- .../Tests/Editor/Vector3Tests.cs | 2 +- 51 files changed, 1738 insertions(+), 43 deletions(-) create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/BeCloseToExtensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/BeCloseToExtensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2IntExtensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2IntExtensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3IntExtensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3IntExtensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector4Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector4Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2IntExtensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2IntExtensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3IntExtensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3IntExtensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector4Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector4Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/BeCloseToExtensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/BeCloseToExtensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float2Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float2Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float4Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float4Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int2Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int2Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int3Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int3Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int4Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int4Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat2Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat2Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat4Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat4Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt2Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt2Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt3Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt3Extensions.cs.meta create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt4Extensions.cs create mode 100644 FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt4Extensions.cs.meta diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/BoundfoxStudios.FluentAssertions.asmdef b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/BoundfoxStudios.FluentAssertions.asmdef index b145159..6d39345 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/BoundfoxStudios.FluentAssertions.asmdef +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/BoundfoxStudios.FluentAssertions.asmdef @@ -11,4 +11,4 @@ "defineConstraints": [], "versionDefines": [], "noEngineReferences": false -} +} \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs index ba5ff59..df7fde1 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Assertions/MathematicsAssertions.cs @@ -82,16 +82,6 @@ public AndConstraint BeOneOf(IEnumerable validValues, str return new((TAssertions)this); } - public AndConstraint BeApproximately(TSubject expected, float precision, string because = "", params object[] becauseArgs) - { - Execute.Assertion - .ForCondition(Subject is { } value && CalculateApproximately(value, expected, precision)) - .BecauseOf(because, becauseArgs) - .FailWith("Expected {context:value} to be {0}{reason}, but found {1}" + GenerateDifferenceMessage(expected), expected, Subject); - - return new((TAssertions)this); - } - public AndConstraint BeOfType(Type expectedType, string because = "", params object[] becauseArgs) { Guard.AgainstNull(expectedType, nameof(expectedType)); @@ -137,8 +127,6 @@ public AndConstraint Match(Expression> predica return new((TAssertions)this); } - protected abstract bool CalculateApproximately(TSubject subject, TSubject expected, float precision); - [CanBeNull] private protected virtual string CalculateDifferenceForFailureMessage(TSubject subject, TSubject expected) => null; diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/BeCloseToExtensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/BeCloseToExtensions.cs new file mode 100644 index 0000000..9a78e2a --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/BeCloseToExtensions.cs @@ -0,0 +1,631 @@ +using System; +using FluentAssertions; +using FluentAssertions.Execution; +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class BeCloseToExtensions + { + #region BeCloseTo + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent, Vector2 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector2 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector2Assertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector2? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent, Vector3 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector3 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector3Assertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector3? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent, Vector4 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector4 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector4Assertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector4? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent, Vector2Int other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector2Int other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector2IntAssertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector2Int? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent, Vector3Int other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector3Int other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector3IntAssertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, Vector3Int? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + #endregion + + #region NotBeCloseTo + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent, Vector2 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector2 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector2Assertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector2? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.NotBeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent, Vector3 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector3 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector3Assertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector3? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.NotBeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent, Vector4 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector4 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector4Assertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector2? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.NotBeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent, Vector2Int other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector2Int other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector2IntAssertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector2Int? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.NotBeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent, Vector3Int other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = difference.magnitude; + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector3Int other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Vector3IntAssertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent, Vector3Int? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.NotBeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + #endregion + + private static void FailIfDifferenceOutsidePrecision( + bool differenceWithinPrecision, + MathematicsAssertions parent, T expectedValue, float precision, T actualDifference, + string because, object[] becauseArgs) + where T : struct, IEquatable, IFormattable + { + Execute.Assertion + .ForCondition(differenceWithinPrecision) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {1} +/- {2}{reason}, but {0} differed by {3}.", + parent.Subject, expectedValue, precision, actualDifference); + } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/BeCloseToExtensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/BeCloseToExtensions.cs.meta new file mode 100644 index 0000000..ca02486 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/BeCloseToExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: af56ee7f5dbc437db277e87bc7139945 +timeCreated: 1677530202 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2Extensions.cs new file mode 100644 index 0000000..06b377c --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2Extensions.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class NullableVector2Extensions + { + public static NullableVector2Assertions Should(this Vector2? instance) => new(instance); + } + + public class NullableVector2Assertions : NullableMathematicsAssertions + { + public NullableVector2Assertions(Vector2? subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2Extensions.cs.meta new file mode 100644 index 0000000..71d6755 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 70a46832af29422d9e14b0cd196214a2 +timeCreated: 1677076743 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2IntExtensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2IntExtensions.cs new file mode 100644 index 0000000..19fd75d --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2IntExtensions.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class NullableVector2IntExtensions + { + public static NullableVector2IntAssertions Should(this Vector2Int? instance) => new(instance); + } + + public class NullableVector2IntAssertions : NullableMathematicsAssertions + { + public NullableVector2IntAssertions(Vector2Int? subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2IntExtensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2IntExtensions.cs.meta new file mode 100644 index 0000000..4630776 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector2IntExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 01957c34e57e4451b771078dcb057af2 +timeCreated: 1677076810 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs index a10d084..1e6608c 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3Extensions.cs @@ -10,6 +10,5 @@ public static class NullableVector3Extensions public class NullableVector3Assertions : NullableMathematicsAssertions { public NullableVector3Assertions(Vector3? subject) : base(subject) { } - protected override bool CalculateApproximately(Vector3 subject, Vector3 expected, float precision) => (subject - expected).sqrMagnitude < precision; } } diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3IntExtensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3IntExtensions.cs new file mode 100644 index 0000000..d60d393 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3IntExtensions.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class NullableVector3IntExtensions + { + public static NullableVector3IntAssertions Should(this Vector3Int? instance) => new(instance); + } + + public class NullableVector3IntAssertions : NullableMathematicsAssertions + { + public NullableVector3IntAssertions(Vector3Int? subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3IntExtensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3IntExtensions.cs.meta new file mode 100644 index 0000000..d06581b --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector3IntExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d695d0665e4b48cc9e0011e5df973821 +timeCreated: 1677076864 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector4Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector4Extensions.cs new file mode 100644 index 0000000..007ba24 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector4Extensions.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class NullableVector4Extensions + { + public static NullableVector4Assertions Should(this Vector4? instance) => new(instance); + } + + public class NullableVector4Assertions : NullableMathematicsAssertions + { + public NullableVector4Assertions(Vector4? subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector4Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector4Extensions.cs.meta new file mode 100644 index 0000000..a9e567e --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/NullableVector4Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fac43fcfb36445c1ad812004c79c6ffa +timeCreated: 1677076770 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2Extensions.cs new file mode 100644 index 0000000..6f5c036 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2Extensions.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class Vector2Extensions + { + public static Vector2Assertions Should(this Vector2 instance) => new(instance); + } + + public class Vector2Assertions : MathematicsAssertions + { + public Vector2Assertions(Vector2 subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2Extensions.cs.meta new file mode 100644 index 0000000..03ce615 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 39e85e0edadb4f9a9e2000616900b215 +timeCreated: 1677076743 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2IntExtensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2IntExtensions.cs new file mode 100644 index 0000000..afe25c7 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2IntExtensions.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class Vector2IntExtensions + { + public static Vector2IntAssertions Should(this Vector2Int instance) => new(instance); + } + + public class Vector2IntAssertions : MathematicsAssertions + { + public Vector2IntAssertions(Vector2Int subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2IntExtensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2IntExtensions.cs.meta new file mode 100644 index 0000000..bc55673 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector2IntExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cd94f42c4a664e0b97193ba8bf265e35 +timeCreated: 1677076810 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs index 7ecf996..9083237 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3Extensions.cs @@ -10,6 +10,5 @@ public static class Vector3Extensions public class Vector3Assertions : MathematicsAssertions { public Vector3Assertions(Vector3 subject) : base(subject) { } - protected override bool CalculateApproximately(Vector3 subject, Vector3 expected, float precision) => (subject - expected).sqrMagnitude < precision; } } diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3IntExtensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3IntExtensions.cs new file mode 100644 index 0000000..504d4f1 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3IntExtensions.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class Vector3IntExtensions + { + public static Vector3IntAssertions Should(this Vector3Int instance) => new(instance); + } + + public class Vector3IntAssertions : MathematicsAssertions + { + public Vector3IntAssertions(Vector3Int subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3IntExtensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3IntExtensions.cs.meta new file mode 100644 index 0000000..d5bc8ea --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector3IntExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 93cce7f0148d4169912ba1848745bbd5 +timeCreated: 1677076864 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector4Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector4Extensions.cs new file mode 100644 index 0000000..bccb062 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector4Extensions.cs @@ -0,0 +1,14 @@ +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class Vector4Extensions + { + public static Vector4Assertions Should(this Vector4 instance) => new(instance); + } + + public class Vector4Assertions : MathematicsAssertions + { + public Vector4Assertions(Vector4 subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector4Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector4Extensions.cs.meta new file mode 100644 index 0000000..5558f76 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Extensions/Vector4Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 54f8d9656688483190b42090a207c4f2 +timeCreated: 1677076770 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef index 7450f4a..20a7092 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.asmdef @@ -1,21 +1,27 @@ { - "name": "BoundfoxStudios.FluentAssertions.Mathematics", - "rootNamespace": "BoundfoxStudios.FluentAssertions.Mathematics", - "references": [ - "GUID:d8b63aba1907145bea998dd612889d6b", - "GUID:e372c541aba5148868e12aa078ca7c20" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [ - "FLUENTASSERTIONS_UNITY_MATHEMATICS" - ], - "versionDefines": [], - "noEngineReferences": false -} + "name": "BoundfoxStudios.FluentAssertions.Mathematics", + "rootNamespace": "BoundfoxStudios.FluentAssertions.Mathematics", + "references": [ + "GUID:d8b63aba1907145bea998dd612889d6b", + "GUID:e372c541aba5148868e12aa078ca7c20" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [ + "FLUENTASSERTIONS_UNITY_MATHEMATICS" + ], + "versionDefines": [ + { + "name": "com.unity.mathematics", + "expression": "", + "define": "FLUENTASSERTIONS_UNITY_MATHEMATICS" + } + ], + "noEngineReferences": false +} \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/BeCloseToExtensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/BeCloseToExtensions.cs new file mode 100644 index 0000000..25f9c17 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/BeCloseToExtensions.cs @@ -0,0 +1,753 @@ +using System; +using BoundfoxStudios.FluentAssertions.Mathematics; +using FluentAssertions; +using FluentAssertions.Execution; +using Unity.Mathematics; +using UnityEngine; + +namespace BoundfoxStudios.FluentAssertions +{ + public static class BeCloseToExtensions + { + #region BeCloseTo + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent, float3 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, float3 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Float3Assertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, float3? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent, float2 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, float2 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Float2Assertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, float2? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent, float4 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, float4 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Float4Assertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent, float4? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent,int2 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent,int2 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Int2Assertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent,int2? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent,int3 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent,int3 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Int3Assertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent,int3? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this MathematicsAssertions parent,int4 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance <= maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent,int4 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Int4Assertions(parent.Subject.Value); + nonNullableAssertions.BeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> BeCloseTo(this NullableMathematicsAssertions parent,int4? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + #endregion + + #region NotBeCloseTo + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent,int2 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,int2 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Int2Assertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,int2? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent,int3 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,int3 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Int3Assertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,int3? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent,int4 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,int4 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Int4Assertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,int4? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent,float2 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,float2 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Float2Assertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,float2? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent,float3 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,float3 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Float3Assertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,float3? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this MathematicsAssertions parent,float4 other, float maxDistance, string because = "", + params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + var difference = other - parent.Subject.Value; + var distance = math.length(difference); + FailIfDifferenceOutsidePrecision(distance > maxDistance, parent, other, maxDistance, difference, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,float4 other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + Execute.Assertion + .ForCondition(parent.Subject is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {0} +/- {1}{reason}, but it was .", other, maxDistance); + + var nonNullableAssertions = new Float4Assertions(parent.Subject.Value); + nonNullableAssertions.NotBeCloseTo(other, maxDistance, because, becauseArgs); + + return new(parent); + } + + public static AndConstraint> NotBeCloseTo(this NullableMathematicsAssertions parent,float4? other, float maxDistance, + string because = "", params object[] becauseArgs) + { + if (maxDistance < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxDistance), $"The value of {nameof(maxDistance)} must be non-negative."); + } + + if (parent.Subject is null && other is null) + { + return new(parent); + } + + var succeeded = Execute.Assertion + .ForCondition(other is not null) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to be close to {0} +/- {1}{reason}, but it was {2}.", other, maxDistance, parent.Subject); + + if (succeeded) + { + parent.BeCloseTo(other.Value, maxDistance, because, becauseArgs); + } + + return new(parent); + } + + #endregion + + private static void FailIfDifferenceOutsidePrecision( + bool differenceWithinPrecision, + MathematicsAssertions parent, T expectedValue, float precision, T actualDifference, + string because, object[] becauseArgs) + where T : struct, IEquatable, IFormattable + { + Execute.Assertion + .ForCondition(differenceWithinPrecision) + .BecauseOf(because, becauseArgs) + .FailWith("Expected {context:value} to approximate {1} +/- {2}{reason}, but {0} differed by {3}.", + parent.Subject, expectedValue, precision, actualDifference); + } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/BeCloseToExtensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/BeCloseToExtensions.cs.meta new file mode 100644 index 0000000..d811001 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/BeCloseToExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b2d2fd2e5f7f4672b0ca83f8c636ffcf +timeCreated: 1677532279 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float2Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float2Extensions.cs new file mode 100644 index 0000000..de62fa6 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float2Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class Float2Extensions + { + public static Float2Assertions Should(this float2 instance) => new(instance); + } + + public class Float2Assertions : MathematicsAssertions + { + public Float2Assertions(float2 subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float2Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float2Extensions.cs.meta new file mode 100644 index 0000000..a54b4ac --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float2Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 60785e302cba492f8d24ebc5b62e8e42 +timeCreated: 1677532400 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs index 461dbfb..ff94462 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float3Extensions.cs @@ -10,7 +10,5 @@ public static class Float3Extensions public class Float3Assertions : MathematicsAssertions { public Float3Assertions(float3 subject) : base(subject) { } - - protected override bool CalculateApproximately(float3 subject, float3 expected, float precision) => math.lengthsq(subject - expected) < precision; } } diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float4Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float4Extensions.cs new file mode 100644 index 0000000..5848157 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float4Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class Float4Extensions + { + public static Float4Assertions Should(this float4 instance) => new(instance); + } + + public class Float4Assertions : MathematicsAssertions + { + public Float4Assertions(float4 subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float4Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float4Extensions.cs.meta new file mode 100644 index 0000000..081e8d6 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Float4Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bec6bde65729422c900e9de1762fe1f4 +timeCreated: 1677532488 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int2Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int2Extensions.cs new file mode 100644 index 0000000..cd4318c --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int2Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class Int2Extensions + { + public static Int2Assertions Should(this int2 instance) => new(instance); + } + + public class Int2Assertions : MathematicsAssertions + { + public Int2Assertions(int2 subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int2Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int2Extensions.cs.meta new file mode 100644 index 0000000..be913dd --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int2Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ee73984a4f9a4d31933102a0c752b4f3 +timeCreated: 1677532638 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int3Extensions.cs new file mode 100644 index 0000000..10f4df8 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int3Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class Int3Extensions + { + public static Int3Assertions Should(this int3 instance) => new(instance); + } + + public class Int3Assertions : MathematicsAssertions + { + public Int3Assertions(int3 subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int3Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int3Extensions.cs.meta new file mode 100644 index 0000000..eb80600 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int3Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 654ae6385cfe4b78958a531cff1f1622 +timeCreated: 1677532736 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int4Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int4Extensions.cs new file mode 100644 index 0000000..74d0da3 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int4Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class Int4Extensions + { + public static Int4Assertions Should(this int4 instance) => new(instance); + } + + public class Int4Assertions : MathematicsAssertions + { + public Int4Assertions(int4 subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int4Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int4Extensions.cs.meta new file mode 100644 index 0000000..609aa30 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/Int4Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 43dc70dc54234e05907826beaf5f1524 +timeCreated: 1677532771 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat2Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat2Extensions.cs new file mode 100644 index 0000000..a348b85 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat2Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class NullableFloat2Extensions + { + public static NullableFloat2Assertions Should(this float2? instance) => new(instance); + } + + public class NullableFloat2Assertions : NullableMathematicsAssertions + { + public NullableFloat2Assertions(float2? subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat2Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat2Extensions.cs.meta new file mode 100644 index 0000000..cabde41 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat2Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a1d7320de8ed4949a5bb0abeb0495f44 +timeCreated: 1677532400 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs index 87fceba..9ddee59 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat3Extensions.cs @@ -10,7 +10,5 @@ public static class NullableFloat3Extensions public class NullableFloat3Assertions : NullableMathematicsAssertions { public NullableFloat3Assertions(float3? subject) : base(subject) { } - - protected override bool CalculateApproximately(float3 subject, float3 expected, float precision) => math.lengthsq(subject - expected) < precision; } } diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat4Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat4Extensions.cs new file mode 100644 index 0000000..5e1489e --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat4Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class NullableFloat4Extensions + { + public static NullableFloat4Assertions Should(this float4? instance) => new(instance); + } + + public class NullableFloat4Assertions : NullableMathematicsAssertions + { + public NullableFloat4Assertions(float4? subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat4Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat4Extensions.cs.meta new file mode 100644 index 0000000..89cc5b0 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableFloat4Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 510e03a1b0be4c52858728ad6b8da958 +timeCreated: 1677532488 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt2Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt2Extensions.cs new file mode 100644 index 0000000..84f1874 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt2Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class NullableInt2Extensions + { + public static NullableInt2Assertions Should(this int2? instance) => new(instance); + } + + public class NullableInt2Assertions : NullableMathematicsAssertions + { + public NullableInt2Assertions(int2? subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt2Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt2Extensions.cs.meta new file mode 100644 index 0000000..cb8dcf3 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt2Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 37a765dbdd794ba593cbfea13bf9d5a8 +timeCreated: 1677532638 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt3Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt3Extensions.cs new file mode 100644 index 0000000..2e3e1a9 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt3Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class NullableInt3Extensions + { + public static NullableInt3Assertions Should(this int3? instance) => new(instance); + } + + public class NullableInt3Assertions : NullableMathematicsAssertions + { + public NullableInt3Assertions(int3? subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt3Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt3Extensions.cs.meta new file mode 100644 index 0000000..2ab034e --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt3Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8862e57af0ea48cfa40e4a59bd77723a +timeCreated: 1677532736 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt4Extensions.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt4Extensions.cs new file mode 100644 index 0000000..6df6267 --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt4Extensions.cs @@ -0,0 +1,14 @@ +using Unity.Mathematics; + +namespace BoundfoxStudios.FluentAssertions.Mathematics +{ + public static class NullableInt4Extensions + { + public static NullableInt4Assertions Should(this int4? instance) => new(instance); + } + + public class NullableInt4Assertions : NullableMathematicsAssertions + { + public NullableInt4Assertions(int4? subject) : base(subject) { } + } +} diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt4Extensions.cs.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt4Extensions.cs.meta new file mode 100644 index 0000000..a71024c --- /dev/null +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Runtime/UnityAdoption/Mathematics/Extensions/NullableInt4Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 037c21ec45c64ae0aa5da3f4b9fe4190 +timeCreated: 1677532771 \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef index 878199e..8a66689 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef @@ -22,6 +22,12 @@ "UNITY_INCLUDE_TESTS", "FLUENTASSERTIONS_UNITY_MATHEMATICS" ], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.unity.mathematics", + "expression": "", + "define": "FLUENTASSERTIONS_UNITY_MATHEMATICS" + } + ], "noEngineReferences": false } \ No newline at end of file diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef.meta b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef.meta index 7803b83..8884d04 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef.meta +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/BoundfoxStudios.FluentAssertions.Mathematics.Editor.Tests.asmdef.meta @@ -1,3 +1,7 @@ fileFormatVersion: 2 guid: 8dddd9b03f7c4f59adbe56c5f7bfbe9d -timeCreated: 1677058134 \ No newline at end of file +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs index 32abbd3..180bdf2 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Mathematics/Float3Tests.cs @@ -1,3 +1,4 @@ +using FluentAssertions; using NUnit.Framework; using Unity.Mathematics; @@ -31,7 +32,7 @@ public void Float3BeApproximatelyPasses() var expected = new float3(0.2672612f, 0.5345225f, 0.8017837f); var normalized = math.normalize(v1); - normalized.Should().BeApproximately(expected, 0.5f); + normalized.Should().BeCloseTo(expected, 0.5f); } } } diff --git a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs index 09d73b5..96de515 100644 --- a/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs +++ b/FluentAssertions/Packages/com.boundfoxstudios.fluentassertions/Tests/Editor/Vector3Tests.cs @@ -31,7 +31,7 @@ public void Vector3BeApproximatelyPasses() var expected = new Vector3(0.2672612f, 0.5345225f, 0.8017837f); var normalized = v1.normalized; - normalized.Should().BeApproximately(expected, 0.5f); + normalized.Should().BeCloseTo(expected, 0.5f); } } }