test: replace playmode tests with NUnit tests (#76)

Using yield break; in a coroutine which does not need to be one, that's a paddlin'.
This commit is contained in:
Oliver Booth 2023-04-05 19:18:06 +01:00
parent e84eef60e6
commit 5d2313fa20
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
20 changed files with 202 additions and 394 deletions

View File

@ -1,8 +1,6 @@
using System;
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Unity.Drawing;
namespace X10D.Unity.Tests.Drawing
@ -18,8 +16,8 @@ namespace X10D.Unity.Tests.Drawing
private static readonly Color32 Magenta = new(255, 0, 255, 255);
private static readonly Color32 Yellow = new(255, 255, 0, 255);
[UnityTest]
public IEnumerator Deconstruct_ShouldDeconstruct_ToCorrectValues()
[Test]
public void Deconstruct_ShouldDeconstruct_ToCorrectValues()
{
byte a, r, g, b;
@ -33,12 +31,10 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(255, r);
Assert.AreEqual(255, g);
Assert.AreEqual(0, b);
yield break;
}
[UnityTest]
public IEnumerator GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor()
[Test]
public void GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor()
{
// I know it's just casting... but aim for 100% coverage babyyyy
@ -53,12 +49,10 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(ConsoleColor.Gray, ((Color32)Color.gray).GetClosestConsoleColor());
Assert.AreEqual(ConsoleColor.Gray, ((Color32)Color.grey).GetClosestConsoleColor());
Assert.AreEqual(ConsoleColor.Black, ((Color32)Color.clear).GetClosestConsoleColor());
yield break;
}
[UnityTest]
public IEnumerator Inverted_ShouldReturnInvertedColor()
[Test]
public void Inverted_ShouldReturnInvertedColor()
{
Assert.AreEqual(White, Black.Inverted());
Assert.AreEqual(Black, White.Inverted());
@ -68,78 +62,62 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(Magenta, Green.Inverted());
Assert.AreEqual(Yellow, Blue.Inverted());
Assert.AreEqual(Blue, Yellow.Inverted());
yield break;
}
[UnityTest]
public IEnumerator Inverted_ShouldIgnoreAlpha()
[Test]
public void Inverted_ShouldIgnoreAlpha()
{
var expected = new Color32(0, 0, 0, 255);
var actual = new Color32(255, 255, 255, 255).Inverted();
Assert.AreEqual(expected, actual);
yield break;
}
[UnityTest]
public IEnumerator ToSystemDrawingColor_ShouldReturnEquivalentColor()
[Test]
public void ToSystemDrawingColor_ShouldReturnEquivalentColor()
{
System.Drawing.Color expected = System.Drawing.Color.FromArgb(255, 255, 255);
System.Drawing.Color actual = White.ToSystemDrawingColor();
Assert.AreEqual(expected, actual);
yield break;
}
[UnityTest]
public IEnumerator ToUnityColor32_ShouldReturnEquivalentColor()
[Test]
public void ToUnityColor32_ShouldReturnEquivalentColor()
{
Color32 expected = White;
Color32 actual = System.Drawing.Color.FromArgb(255, 255, 255).ToUnityColor32();
Assert.AreEqual(expected, actual);
yield break;
}
[UnityTest]
public IEnumerator WithA0_ShouldReturnSameColor_GivenWhite()
[Test]
public void WithA0_ShouldReturnSameColor_GivenWhite()
{
var transparent = new Color32(255, 255, 255, 0);
Assert.AreEqual(transparent, White.WithA(0));
Assert.AreEqual(transparent, transparent.WithA(0));
yield break;
}
[UnityTest]
public IEnumerator WithB0_ShouldReturnYellow_GivenWhite()
[Test]
public void WithB0_ShouldReturnYellow_GivenWhite()
{
Assert.AreEqual(Yellow, White.WithB(0));
Assert.AreEqual(Yellow, Yellow.WithB(0));
yield break;
}
[UnityTest]
public IEnumerator WithG0_ShouldReturnMagenta_GivenWhite()
[Test]
public void WithG0_ShouldReturnMagenta_GivenWhite()
{
Assert.AreEqual(Magenta, White.WithG(0));
Assert.AreEqual(Magenta, Magenta.WithG(0));
yield break;
}
[UnityTest]
public IEnumerator WithR0_ShouldReturnCyan_GivenWhite()
[Test]
public void WithR0_ShouldReturnCyan_GivenWhite()
{
Assert.AreEqual(Cyan, White.WithR(0));
Assert.AreEqual(Cyan, Cyan.WithR(0));
yield break;
}
}
}

View File

@ -1,10 +1,6 @@
using System;
using System.Collections;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Unity.Drawing;
namespace X10D.Unity.Tests.Drawing
@ -20,8 +16,8 @@ namespace X10D.Unity.Tests.Drawing
private static readonly Color Magenta = new(1, 0, 1);
private static readonly Color Yellow = new(1, 1, 0);
[UnityTest]
public IEnumerator Deconstruct_ShouldDeconstruct_ToCorrectValues()
[Test]
public void Deconstruct_ShouldDeconstruct_ToCorrectValues()
{
float a, r, g, b;
@ -35,12 +31,10 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(1.0f, r);
Assert.AreEqual(1.0f, g);
Assert.AreEqual(0.0f, b);
yield break;
}
[UnityTest]
public IEnumerator GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor()
[Test]
public void GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor()
{
Assert.AreEqual(ConsoleColor.Red, Color.red.GetClosestConsoleColor());
Assert.AreEqual(ConsoleColor.Green, Color.green.GetClosestConsoleColor());
@ -53,12 +47,10 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(ConsoleColor.Gray, Color.gray.GetClosestConsoleColor());
Assert.AreEqual(ConsoleColor.Gray, Color.grey.GetClosestConsoleColor());
Assert.AreEqual(ConsoleColor.Black, Color.clear.GetClosestConsoleColor());
yield break;
}
[UnityTest]
public IEnumerator Inverted_ShouldReturnInvertedColor()
[Test]
public void Inverted_ShouldReturnInvertedColor()
{
Assert.AreEqual(White, Black.Inverted());
Assert.AreEqual(Black, White.Inverted());
@ -68,78 +60,62 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(Magenta, Green.Inverted());
Assert.AreEqual(Yellow, Blue.Inverted());
Assert.AreEqual(Blue, Yellow.Inverted());
yield break;
}
[UnityTest]
public IEnumerator Inverted_ShouldIgnoreAlpha()
[Test]
public void Inverted_ShouldIgnoreAlpha()
{
var expected = new Color(0, 0, 0, 1);
var actual = new Color(1, 1, 1, 1).Inverted();
Assert.AreEqual(expected, actual);
yield break;
}
[UnityTest]
public IEnumerator ToSystemDrawingColor_ShouldReturnEquivalentColor()
[Test]
public void ToSystemDrawingColor_ShouldReturnEquivalentColor()
{
System.Drawing.Color expected = System.Drawing.Color.FromArgb(255, 255, 255);
System.Drawing.Color actual = White.ToSystemDrawingColor();
Assert.AreEqual(expected, actual);
yield break;
}
[UnityTest]
public IEnumerator ToUnityColor_ShouldReturnEquivalentColor()
[Test]
public void ToUnityColor_ShouldReturnEquivalentColor()
{
Color expected = White;
Color actual = System.Drawing.Color.FromArgb(255, 255, 255).ToUnityColor();
Assert.AreEqual(expected, actual);
yield break;
}
[UnityTest]
public IEnumerator WithA0_ShouldReturnSameColor_GivenWhite()
[Test]
public void WithA0_ShouldReturnSameColor_GivenWhite()
{
var transparent = new Color(1, 1, 1, 0);
Assert.AreEqual(transparent, White.WithA(0));
Assert.AreEqual(transparent, transparent.WithA(0));
yield break;
}
[UnityTest]
public IEnumerator WithB0_ShouldReturnYellow_GivenWhite()
[Test]
public void WithB0_ShouldReturnYellow_GivenWhite()
{
Assert.AreEqual(Yellow, White.WithB(0));
Assert.AreEqual(Yellow, Yellow.WithB(0));
yield break;
}
[UnityTest]
public IEnumerator WithG0_ShouldReturnMagenta_GivenWhite()
[Test]
public void WithG0_ShouldReturnMagenta_GivenWhite()
{
Assert.AreEqual(Magenta, White.WithG(0));
Assert.AreEqual(Magenta, Magenta.WithG(0));
yield break;
}
[UnityTest]
public IEnumerator WithR0_ShouldReturnCyan_GivenWhite()
[Test]
public void WithR0_ShouldReturnCyan_GivenWhite()
{
Assert.AreEqual(Cyan, White.WithR(0));
Assert.AreEqual(Cyan, Cyan.WithR(0));
yield break;
}
}
}

View File

@ -1,8 +1,6 @@
using System;
using System.Collections;
using System.Drawing;
using NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Core;
using X10D.Unity.Drawing;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Drawing
{
public class PointFTests
{
[UnityTest]
public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
[Test]
public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
{
var random = new Random();
var point = new PointF(random.NextSingle(), random.NextSingle());
@ -19,8 +17,6 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(point.X, vector.x, 1e-6f);
Assert.AreEqual(point.Y, vector.y, 1e-6f);
yield break;
}
}
}

View File

@ -1,16 +1,14 @@
using System;
using System.Collections;
using System.Drawing;
using NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Unity.Drawing;
namespace X10D.Unity.Tests.Drawing
{
public class PointTests
{
[UnityTest]
public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
[Test]
public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
{
var random = new Random();
var point = new Point(random.Next(), random.Next());
@ -18,12 +16,10 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(point.X, vector.x);
Assert.AreEqual(point.Y, vector.y);
yield break;
}
[UnityTest]
public IEnumerator ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers()
[Test]
public void ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers()
{
var random = new Random();
var point = new Point(random.Next(), random.Next());
@ -31,8 +27,6 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(point.X, vector.x);
Assert.AreEqual(point.Y, vector.y);
yield break;
}
}
}

View File

@ -1,10 +1,8 @@
#nullable enable
using System;
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Unity.Drawing;
using Random = System.Random;
@ -12,8 +10,8 @@ namespace X10D.Unity.Tests.Drawing
{
public class RandomTests
{
[UnityTest]
public IEnumerator NextColorArgb_ShouldReturn331515e5_GivenSeed1234()
[Test]
public void NextColorArgb_ShouldReturn331515e5_GivenSeed1234()
{
var random = new Random(1234);
var color = random.NextColorArgb();
@ -21,35 +19,31 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(0.391597569f, color.g, 1e-6f);
Assert.AreEqual(0.675019085f, color.b, 1e-6f);
Assert.AreEqual(0.234300315f, color.a, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator NextColorArgb_ShouldThrow_GivenNull()
[Test]
public void NextColorArgb_ShouldThrow_GivenNull()
{
Random? random = null;
Assert.Throws<ArgumentNullException>(() => random!.NextColorArgb());
yield break;
Random random = null!;
Assert.Throws<ArgumentNullException>(() => random.NextColorArgb());
}
[UnityTest]
public IEnumerator NextColor32Argb_ShouldReturn331515e5_GivenSeed1234()
[Test]
public void NextColor32Argb_ShouldReturn331515e5_GivenSeed1234()
{
var random = new Random(1234);
Assert.AreEqual(new Color32(21, 21, 229, 51), random.NextColor32Argb());
yield break;
}
[UnityTest]
public IEnumerator NextColor32Argb_ShouldThrow_GivenNull()
[Test]
public void NextColor32Argb_ShouldThrow_GivenNull()
{
Random? random = null;
Assert.Throws<ArgumentNullException>(() => random!.NextColor32Argb());
yield break;
Random random = null!;
Assert.Throws<ArgumentNullException>(() => random.NextColor32Argb());
}
[UnityTest]
public IEnumerator NextColorRgb_ShouldReturn1515e5_GivenSeed1234()
[Test]
public void NextColorRgb_ShouldReturn1515e5_GivenSeed1234()
{
var random = new Random(1234);
var color = random.NextColorRgb();
@ -57,31 +51,27 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(0.373868465f, color.g, 1e-6f);
Assert.AreEqual(0.391597569f, color.b, 1e-6f);
Assert.AreEqual(1, color.a, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator NextColorRgb_ShouldThrow_GivenNull()
[Test]
public void NextColorRgb_ShouldThrow_GivenNull()
{
Random? random = null;
Assert.Throws<ArgumentNullException>(() => random!.NextColorRgb());
yield break;
Random random = null!;
Assert.Throws<ArgumentNullException>(() => random.NextColorRgb());
}
[UnityTest]
public IEnumerator NextColor32Rgb_ShouldReturn1515e5_GivenSeed1234()
[Test]
public void NextColor32Rgb_ShouldReturn1515e5_GivenSeed1234()
{
var random = new Random(1234);
Assert.AreEqual(new Color32(21, 21, 229, 255), random.NextColor32Rgb());
yield break;
}
[UnityTest]
public IEnumerator NextColor32Rgb_ShouldThrow_GivenNull()
[Test]
public void NextColor32Rgb_ShouldThrow_GivenNull()
{
Random? random = null;
Assert.Throws<ArgumentNullException>(() => random!.NextColor32Rgb());
yield break;
Random random = null!;
Assert.Throws<ArgumentNullException>(() => random.NextColor32Rgb());
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections;
using NUnit.Framework;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Unity.Drawing;
using Random = System.Random;
@ -9,8 +7,8 @@ namespace X10D.Unity.Tests.Drawing
{
public class RectIntTests
{
[UnityTest]
public IEnumerator ToSystemRectangle_ShouldReturnRectangleF_WithEquivalentMembers()
[Test]
public void ToSystemRectangle_ShouldReturnRectangleF_WithEquivalentMembers()
{
var random = new Random();
var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next());
@ -20,12 +18,10 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(rect.y, rectangle.Y);
Assert.AreEqual(rect.width, rectangle.Width);
Assert.AreEqual(rect.height, rectangle.Height);
yield break;
}
[UnityTest]
public IEnumerator ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers()
[Test]
public void ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers()
{
var random = new Random();
var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next());
@ -35,8 +31,6 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(rect.y, rectangle.Y);
Assert.AreEqual(rect.width, rectangle.Width);
Assert.AreEqual(rect.height, rectangle.Height);
yield break;
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections;
using NUnit.Framework;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Core;
using X10D.Unity.Drawing;
using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Drawing
{
public class RectTests
{
[UnityTest]
public IEnumerator ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers()
[Test]
public void ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers()
{
var random = new Random();
var rect = new Rect(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle());
@ -21,8 +19,6 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(rect.y, rectangle.Y, 1e-6f);
Assert.AreEqual(rect.width, rectangle.Width, 1e-6f);
Assert.AreEqual(rect.height, rectangle.Height, 1e-6f);
yield break;
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections;
using System.Drawing;
using System.Drawing;
using NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Core;
using X10D.Unity.Drawing;
using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Drawing
{
public class RectangleFTests
{
[UnityTest]
public IEnumerator ToUnityRect_ShouldReturnRect_WithEquivalentMembers()
[Test]
public void ToUnityRect_ShouldReturnRect_WithEquivalentMembers()
{
var random = new Random();
var rectangle = new RectangleF(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle());
@ -21,8 +19,6 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(rectangle.Y, rect.y, 1e-6f);
Assert.AreEqual(rectangle.Width, rect.width, 1e-6f);
Assert.AreEqual(rectangle.Height, rect.height, 1e-6f);
yield break;
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections;
using System.Drawing;
using System.Drawing;
using NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Unity.Drawing;
using Random = System.Random;
@ -9,8 +7,8 @@ namespace X10D.Unity.Tests.Drawing
{
public class RectangleTests
{
[UnityTest]
public IEnumerator ToUnityRect_ShouldReturnRect_WithEquivalentMembers()
[Test]
public void ToUnityRect_ShouldReturnRect_WithEquivalentMembers()
{
var random = new Random();
var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next());
@ -20,12 +18,10 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(rectangle.Y, rect.y);
Assert.AreEqual(rectangle.Width, rect.width);
Assert.AreEqual(rectangle.Height, rect.height);
yield break;
}
[UnityTest]
public IEnumerator ToUnityRectInt_ShouldReturnRect_WithEquivalentMembers()
[Test]
public void ToUnityRectInt_ShouldReturnRect_WithEquivalentMembers()
{
var random = new Random();
var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next());
@ -35,8 +31,6 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(rectangle.Y, rect.y);
Assert.AreEqual(rectangle.Width, rect.width);
Assert.AreEqual(rectangle.Height, rect.height);
yield break;
}
}
}

View File

@ -1,8 +1,6 @@
using System;
using System.Collections;
using System.Drawing;
using NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Core;
using X10D.Unity.Drawing;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Drawing
{
public class SizeFTests
{
[UnityTest]
public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
[Test]
public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
{
var random = new Random();
var size = new SizeF(random.NextSingle(), random.NextSingle());
@ -19,8 +17,6 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(size.Width, vector.x, 1e-6f);
Assert.AreEqual(size.Height, vector.y, 1e-6f);
yield break;
}
}
}

View File

@ -1,16 +1,14 @@
using System;
using System.Collections;
using System.Drawing;
using NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Unity.Drawing;
namespace X10D.Unity.Tests.Drawing
{
public class SizeTests
{
[UnityTest]
public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
[Test]
public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
{
var random = new Random();
var size = new Size(random.Next(), random.Next());
@ -18,12 +16,10 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(size.Width, vector.x);
Assert.AreEqual(size.Height, vector.y);
yield break;
}
[UnityTest]
public IEnumerator ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers()
[Test]
public void ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers()
{
var random = new Random();
var size = new Size(random.Next(), random.Next());
@ -31,8 +27,6 @@ namespace X10D.Unity.Tests.Drawing
Assert.AreEqual(size.Width, vector.x);
Assert.AreEqual(size.Height, vector.y);
yield break;
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections;
using NUnit.Framework;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Core;
using X10D.Unity.Numerics;
using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Numerics
{
public class QuaternionTests
{
[UnityTest]
public IEnumerator ToSystemQuaternion_ShouldReturnQuaternion_WithEqualComponents()
[Test]
public void ToSystemQuaternion_ShouldReturnQuaternion_WithEqualComponents()
{
var random = new Random();
float x = random.NextSingle();
@ -26,12 +24,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(quaternion.y, systemQuaternion.Y, 1e-6f);
Assert.AreEqual(quaternion.z, systemQuaternion.Z, 1e-6f);
Assert.AreEqual(quaternion.w, systemQuaternion.W, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator ToUnityQuaternion_ShouldReturnQuaternion_WithEqualComponents()
[Test]
public void ToUnityQuaternion_ShouldReturnQuaternion_WithEqualComponents()
{
var random = new Random();
float x = random.NextSingle();
@ -46,8 +42,6 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(quaternion.Y, unityQuaternion.y, 1e-6f);
Assert.AreEqual(quaternion.Z, unityQuaternion.z, 1e-6f);
Assert.AreEqual(quaternion.W, unityQuaternion.w, 1e-6f);
yield break;
}
}
}

View File

@ -1,63 +1,55 @@
#nullable enable
using System;
using System.Collections;
using NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Unity.Numerics;
namespace X10D.Unity.Tests.Numerics
{
public class RandomTests
{
[UnityTest]
public IEnumerator NextUnitVector2_ShouldReturnVector_WithMagnitude1()
[Test]
public void NextUnitVector2_ShouldReturnVector_WithMagnitude1()
{
var random = new Random();
var vector = random.NextUnitVector2();
Assert.AreEqual(1, vector.magnitude, 1e-6);
yield break;
}
[UnityTest]
public IEnumerator NextUnitVector2_ShouldThrow_GivenNullRandom()
[Test]
public void NextUnitVector2_ShouldThrow_GivenNullRandom()
{
Random? random = null;
Assert.Throws<ArgumentNullException>(() => random!.NextUnitVector2());
yield break;
Random random = null!;
Assert.Throws<ArgumentNullException>(() => random.NextUnitVector2());
}
[UnityTest]
public IEnumerator NextUnitVector3_ShouldReturnVector_WithMagnitude1()
[Test]
public void NextUnitVector3_ShouldReturnVector_WithMagnitude1()
{
var random = new Random();
var vector = random.NextUnitVector3();
Assert.AreEqual(1, vector.magnitude, 1e-6);
yield break;
}
[UnityTest]
public IEnumerator NextUnitVector3_ShouldThrow_GivenNullRandom()
[Test]
public void NextUnitVector3_ShouldThrow_GivenNullRandom()
{
Random? random = null;
Assert.Throws<ArgumentNullException>(() => random!.NextUnitVector3());
yield break;
Random random = null!;
Assert.Throws<ArgumentNullException>(() => random.NextUnitVector3());
}
[UnityTest]
public IEnumerator NextRotation_ShouldThrow_GivenNullRandom()
[Test]
public void NextRotation_ShouldThrow_GivenNullRandom()
{
Random random = null;
Assert.Throws<ArgumentNullException>(() => random!.NextRotation());
yield break;
Random random = null!;
Assert.Throws<ArgumentNullException>(() => random.NextRotation());
}
[UnityTest]
public IEnumerator NextRotationUniform_ShouldThrow_GivenNullRandom()
[Test]
public void NextRotationUniform_ShouldThrow_GivenNullRandom()
{
Random? random = null;
Assert.Throws<ArgumentNullException>(() => random!.NextRotationUniform());
yield break;
Random random = null!;
Assert.Throws<ArgumentNullException>(() => random.NextRotationUniform());
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections;
using NUnit.Framework;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Unity.Numerics;
using Random = System.Random;
@ -9,20 +7,18 @@ namespace X10D.Unity.Tests.Numerics
{
public class Vector2IntTests
{
[UnityTest]
public IEnumerator Deconstruct_ShouldReturnCorrectValues()
[Test]
public void Deconstruct_ShouldReturnCorrectValues()
{
var vector = new Vector2Int(1, 2);
(int x, int y) = vector;
Assert.AreEqual(1, x);
Assert.AreEqual(2, y);
yield break;
}
[UnityTest]
public IEnumerator ToSystemPoint_ShouldReturnPoint_WithEquivalentMembers()
[Test]
public void ToSystemPoint_ShouldReturnPoint_WithEquivalentMembers()
{
var random = new Random();
int x = random.Next();
@ -33,12 +29,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, point.X);
Assert.AreEqual(vector.y, point.Y);
yield break;
}
[UnityTest]
public IEnumerator ToSystemSize_ShouldReturnSize_WithEquivalentMembers()
[Test]
public void ToSystemSize_ShouldReturnSize_WithEquivalentMembers()
{
var random = new Random();
int x = random.Next();
@ -49,12 +43,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, point.Width);
Assert.AreEqual(vector.y, point.Height);
yield break;
}
[UnityTest]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector()
[Test]
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{
Assert.AreEqual(Vector2Int.up, Vector2Int.one.WithX(0));
Assert.AreEqual(Vector2Int.zero, Vector2Int.zero.WithX(0));
@ -65,12 +57,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(Vector2Int.right, Vector2Int.zero.WithX(1));
Assert.AreEqual(Vector2Int.right, Vector2Int.right.WithX(1));
Assert.AreEqual(Vector2Int.one, Vector2Int.up.WithX(1));
yield break;
}
[UnityTest]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector()
[Test]
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{
Assert.AreEqual(Vector2Int.right, Vector2Int.one.WithY(0));
Assert.AreEqual(Vector2Int.zero, Vector2Int.zero.WithY(0));
@ -81,8 +71,6 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(Vector2Int.up, Vector2Int.zero.WithY(1));
Assert.AreEqual(Vector2Int.one, Vector2Int.right.WithY(1));
Assert.AreEqual(Vector2Int.up, Vector2Int.up.WithY(1));
yield break;
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections;
using NUnit.Framework;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Core;
using X10D.Unity.Numerics;
using Random = System.Random;
@ -10,44 +8,38 @@ namespace X10D.Unity.Tests.Numerics
{
public class Vector2Tests
{
[UnityTest]
public IEnumerator Deconstruct_ShouldReturnCorrectValues()
[Test]
public void Deconstruct_ShouldReturnCorrectValues()
{
var vector = new Vector2(1, 2);
(float x, float y) = vector;
Assert.AreEqual(1, x);
Assert.AreEqual(2, y);
yield break;
}
[UnityTest]
public IEnumerator Round_ShouldRoundToNearestInteger_GivenNoParameters()
[Test]
public void Round_ShouldRoundToNearestInteger_GivenNoParameters()
{
var vector = new Vector2(1.5f, 2.6f);
var rounded = vector.Round();
Assert.AreEqual(2, rounded.x);
Assert.AreEqual(3, rounded.y);
yield break;
}
[UnityTest]
public IEnumerator Round_ShouldRoundToNearest10_GivenPrecision10()
[Test]
public void Round_ShouldRoundToNearest10_GivenPrecision10()
{
var vector = new Vector2(1.5f, 25.2f);
var rounded = vector.Round(10);
Assert.AreEqual(0, rounded.x);
Assert.AreEqual(30, rounded.y);
yield break;
}
[UnityTest]
public IEnumerator ToSystemPointF_ShouldReturnPoint_WithEquivalentMembers()
[Test]
public void ToSystemPointF_ShouldReturnPoint_WithEquivalentMembers()
{
var random = new Random();
float x = random.NextSingle();
@ -58,12 +50,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, point.X, 1e-6f);
Assert.AreEqual(vector.y, point.Y, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator ToSystemSizeF_ShouldReturnSize_WithEquivalentMembers()
[Test]
public void ToSystemSizeF_ShouldReturnSize_WithEquivalentMembers()
{
var random = new Random();
float x = random.NextSingle();
@ -74,12 +64,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, point.Width, 1e-6f);
Assert.AreEqual(vector.y, point.Height, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents()
[Test]
public void ToSystemVector_ShouldReturnVector_WithEqualComponents()
{
var random = new Random();
float x = random.NextSingle();
@ -91,12 +79,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.magnitude, systemVector.Length(), 1e-6f);
Assert.AreEqual(vector.x, systemVector.X, 1e-6f);
Assert.AreEqual(vector.y, systemVector.Y, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator ToUnityVector_ShouldReturnVector_WithEqualComponents()
[Test]
public void ToUnityVector_ShouldReturnVector_WithEqualComponents()
{
var random = new Random();
float x = random.NextSingle();
@ -108,12 +94,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.Length(), unityVector.magnitude, 1e-6f);
Assert.AreEqual(vector.X, unityVector.x, 1e-6f);
Assert.AreEqual(vector.Y, unityVector.y, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector()
[Test]
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{
Assert.AreEqual(Vector2.up, Vector2.one.WithX(0));
Assert.AreEqual(Vector2.zero, Vector2.zero.WithX(0));
@ -124,12 +108,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(Vector2.right, Vector2.zero.WithX(1));
Assert.AreEqual(Vector2.right, Vector2.right.WithX(1));
Assert.AreEqual(Vector2.one, Vector2.up.WithX(1));
yield break;
}
[UnityTest]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector()
[Test]
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{
Assert.AreEqual(Vector2.right, Vector2.one.WithY(0));
Assert.AreEqual(Vector2.zero, Vector2.zero.WithY(0));
@ -140,8 +122,6 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(Vector2.up, Vector2.zero.WithY(1));
Assert.AreEqual(Vector2.one, Vector2.right.WithY(1));
Assert.AreEqual(Vector2.up, Vector2.up.WithY(1));
yield break;
}
}
}

View File

@ -1,15 +1,13 @@
using System.Collections;
using NUnit.Framework;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Unity.Numerics;
namespace X10D.Unity.Tests.Numerics
{
public class Vector3IntTests
{
[UnityTest]
public IEnumerator Deconstruct_ShouldReturnCorrectValues()
[Test]
public void Deconstruct_ShouldReturnCorrectValues()
{
var vector = new Vector3Int(1, 2, 3);
(float x, float y, float z) = vector;
@ -17,12 +15,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(1, x);
Assert.AreEqual(2, y);
Assert.AreEqual(3, z);
yield break;
}
[UnityTest]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector()
[Test]
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{
Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.one.WithX(0));
Assert.AreEqual(Vector3Int.zero, Vector3Int.zero.WithX(0));
@ -35,12 +31,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(Vector3Int.right, Vector3Int.right.WithX(1));
Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.up.WithX(1));
Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.forward.WithX(1));
yield break;
}
[UnityTest]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector()
[Test]
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{
Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.one.WithY(0));
Assert.AreEqual(Vector3Int.zero, Vector3Int.zero.WithY(0));
@ -53,12 +47,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.right.WithY(1));
Assert.AreEqual(Vector3Int.up, Vector3Int.up.WithY(1));
Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.forward.WithY(1));
yield break;
}
[UnityTest]
public IEnumerator WithZ_ShouldReturnVectorWithNewZ_GivenVector()
[Test]
public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
{
Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.one.WithZ(0));
Assert.AreEqual(Vector3Int.zero, Vector3Int.zero.WithZ(0));
@ -71,8 +63,6 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.right.WithZ(1));
Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.up.WithZ(1));
Assert.AreEqual(Vector3Int.forward, Vector3Int.forward.WithZ(1));
yield break;
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections;
using NUnit.Framework;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Core;
using X10D.Unity.Numerics;
using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Numerics
{
public class Vector3Tests
{
[UnityTest]
public IEnumerator Deconstruct_ShouldReturnCorrectValues()
[Test]
public void Deconstruct_ShouldReturnCorrectValues()
{
var vector = new Vector3(1, 2, 3);
(float x, float y, float z) = vector;
@ -19,12 +17,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(1, x);
Assert.AreEqual(2, y);
Assert.AreEqual(3, z);
yield break;
}
[UnityTest]
public IEnumerator Round_ShouldRoundToNearestInteger_GivenNoParameters()
[Test]
public void Round_ShouldRoundToNearestInteger_GivenNoParameters()
{
var vector = new Vector3(1.5f, 2.6f, -5.2f);
var rounded = vector.Round();
@ -32,12 +28,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(2, rounded.x);
Assert.AreEqual(3, rounded.y);
Assert.AreEqual(-5, rounded.z);
yield break;
}
[UnityTest]
public IEnumerator Round_ShouldRoundToNearest10_GivenPrecision10()
[Test]
public void Round_ShouldRoundToNearest10_GivenPrecision10()
{
var vector = new Vector3(1.5f, 25.2f, -12.5f);
var rounded = vector.Round(10);
@ -45,12 +39,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(0, rounded.x);
Assert.AreEqual(30, rounded.y);
Assert.AreEqual(-10, rounded.z);
yield break;
}
[UnityTest]
public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents()
[Test]
public void ToSystemVector_ShouldReturnVector_WithEqualComponents()
{
var random = new Random();
float x = random.NextSingle();
@ -64,12 +56,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, systemVector.X, 1e-6f);
Assert.AreEqual(vector.y, systemVector.Y, 1e-6f);
Assert.AreEqual(vector.z, systemVector.Z, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator ToUnityVector_ShouldReturnVector_WithEqualComponents()
[Test]
public void ToUnityVector_ShouldReturnVector_WithEqualComponents()
{
var random = new Random();
float x = random.NextSingle();
@ -83,12 +73,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.X, unityVector.x, 1e-6f);
Assert.AreEqual(vector.Y, unityVector.y, 1e-6f);
Assert.AreEqual(vector.Z, unityVector.z, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector()
[Test]
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{
Assert.AreEqual(new Vector3(0, 1, 1), Vector3.one.WithX(0));
Assert.AreEqual(Vector3.zero, Vector3.zero.WithX(0));
@ -101,12 +89,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(Vector3.right, Vector3.right.WithX(1));
Assert.AreEqual(new Vector3(1, 1, 0), Vector3.up.WithX(1));
Assert.AreEqual(new Vector3(1, 0, 1), Vector3.forward.WithX(1));
yield break;
}
[UnityTest]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector()
[Test]
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{
Assert.AreEqual(new Vector3(1, 0, 1), Vector3.one.WithY(0));
Assert.AreEqual(Vector3.zero, Vector3.zero.WithY(0));
@ -119,12 +105,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(new Vector3(1, 1, 0), Vector3.right.WithY(1));
Assert.AreEqual(Vector3.up, Vector3.up.WithY(1));
Assert.AreEqual(new Vector3(0, 1, 1), Vector3.forward.WithY(1));
yield break;
}
[UnityTest]
public IEnumerator WithZ_ShouldReturnVectorWithNewZ_GivenVector()
[Test]
public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
{
Assert.AreEqual(new Vector3(1, 1, 0), Vector3.one.WithZ(0));
Assert.AreEqual(Vector3.zero, Vector3.zero.WithZ(0));
@ -137,8 +121,6 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(new Vector3(1, 0, 1), Vector3.right.WithZ(1));
Assert.AreEqual(new Vector3(0, 1, 1), Vector3.up.WithZ(1));
Assert.AreEqual(Vector3.forward, Vector3.forward.WithZ(1));
yield break;
}
}
}

View File

@ -1,7 +1,5 @@
using System.Collections;
using NUnit.Framework;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using X10D.Core;
using X10D.Unity.Numerics;
using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Numerics
{
public class Vector4Tests
{
[UnityTest]
public IEnumerator Deconstruct_ShouldReturnCorrectValues()
[Test]
public void Deconstruct_ShouldReturnCorrectValues()
{
var vector = new Vector4(1, 2, 3, 4);
(float x, float y, float z, float w) = vector;
@ -20,12 +18,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(2, y);
Assert.AreEqual(3, z);
Assert.AreEqual(4, w);
yield break;
}
[UnityTest]
public IEnumerator Round_ShouldRoundToNearestInteger_GivenNoParameters()
[Test]
public void Round_ShouldRoundToNearestInteger_GivenNoParameters()
{
var vector = new Vector4(1.5f, 2.6f, -5.2f, 0.3f);
var rounded = vector.Round();
@ -34,12 +30,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(3, rounded.y);
Assert.AreEqual(-5, rounded.z);
Assert.AreEqual(0, rounded.w);
yield break;
}
[UnityTest]
public IEnumerator Round_ShouldRoundToNearest10_GivenPrecision10()
[Test]
public void Round_ShouldRoundToNearest10_GivenPrecision10()
{
var vector = new Vector4(1.5f, 25.2f, -12.5f, 101.2f);
var rounded = vector.Round(10);
@ -48,12 +42,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(30, rounded.y);
Assert.AreEqual(-10, rounded.z);
Assert.AreEqual(100, rounded.w);
yield break;
}
[UnityTest]
public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents()
[Test]
public void ToSystemVector_ShouldReturnVector_WithEqualComponents()
{
var random = new Random();
float x = random.NextSingle();
@ -69,12 +61,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.y, systemVector.Y, 1e-6f);
Assert.AreEqual(vector.z, systemVector.Z, 1e-6f);
Assert.AreEqual(vector.w, systemVector.W, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator ToUnityVector_ShouldReturnVector_WithEqualComponents()
[Test]
public void ToUnityVector_ShouldReturnVector_WithEqualComponents()
{
var random = new Random();
float x = random.NextSingle();
@ -90,12 +80,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.Y, unityVector.y, 1e-6f);
Assert.AreEqual(vector.Z, unityVector.z, 1e-6f);
Assert.AreEqual(vector.W, unityVector.w, 1e-6f);
yield break;
}
[UnityTest]
public IEnumerator WithW_ShouldReturnVectorWithNewW_GivenVector()
[Test]
public void WithW_ShouldReturnVectorWithNewW_GivenVector()
{
Assert.AreEqual(new Vector4(1, 1, 1, 0), Vector4.one.WithW(0));
Assert.AreEqual(Vector4.zero, Vector4.zero.WithW(0));
@ -110,12 +98,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(new Vector4(1, 0, 0, 1), new Vector4(1, 0, 0, 0).WithW(1));
Assert.AreEqual(new Vector4(0, 1, 0, 1), new Vector4(0, 1, 0, 0).WithW(1));
Assert.AreEqual(new Vector4(0, 0, 1, 1), new Vector4(0, 0, 1, 0).WithW(1));
yield break;
}
[UnityTest]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector()
[Test]
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{
Assert.AreEqual(new Vector4(0, 1, 1, 1), Vector4.one.WithX(0));
Assert.AreEqual(Vector4.zero, Vector4.zero.WithX(0));
@ -130,12 +116,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(new Vector4(1, 0, 0, 0), new Vector4(1, 0, 0, 0).WithX(1));
Assert.AreEqual(new Vector4(1, 1, 0, 0), new Vector4(0, 1, 0, 0).WithX(1));
Assert.AreEqual(new Vector4(1, 0, 1, 0), new Vector4(0, 0, 1, 0).WithX(1));
yield break;
}
[UnityTest]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector()
[Test]
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{
Assert.AreEqual(new Vector4(1, 0, 1, 1), Vector4.one.WithY(0));
Assert.AreEqual(Vector4.zero, Vector4.zero.WithY(0));
@ -150,12 +134,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(new Vector4(1, 1, 0, 0), new Vector4(1, 0, 0, 0).WithY(1));
Assert.AreEqual(new Vector4(0, 1, 0, 0), new Vector4(0, 1, 0, 0).WithY(1));
Assert.AreEqual(new Vector4(0, 1, 1, 0), new Vector4(0, 0, 1, 0).WithY(1));
yield break;
}
[UnityTest]
public IEnumerator WithZ_ShouldReturnVectorWithNewZ_GivenVector()
[Test]
public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
{
Assert.AreEqual(new Vector4(1, 1, 0, 1), Vector4.one.WithZ(0));
Assert.AreEqual(Vector4.zero, Vector4.zero.WithZ(0));
@ -170,8 +152,6 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(new Vector4(1, 0, 1, 0), new Vector4(1, 0, 0, 0).WithZ(1));
Assert.AreEqual(new Vector4(0, 1, 1, 0), new Vector4(0, 1, 0, 0).WithZ(1));
Assert.AreEqual(new Vector4(0, 0, 1, 0), new Vector4(0, 0, 1, 0).WithZ(1));
yield break;
}
}
}

View File

@ -7,33 +7,31 @@ namespace X10D.Unity.Tests
{
public class SingletonTests
{
[UnityTest]
public IEnumerator Singleton_ShouldReturnNewInstance_WhenNoInstanceExists()
[Test]
public void Singleton_ShouldReturnNewInstance_WhenNoInstanceExists()
{
TestBehaviour instance = Singleton<TestBehaviour>.Instance;
Assert.IsTrue(instance);
Assert.IsNotNull(instance);
Assert.IsTrue(instance.Flag);
yield break;
}
[UnityTest]
public IEnumerator Singleton_ShouldReturnSameInstance_WhenAccessedTwice()
[Test]
public void Singleton_ShouldReturnSameInstance_WhenAccessedTwice()
{
TestBehaviour instance = Singleton<TestBehaviour>.Instance;
Assert.IsTrue(instance);
Assert.IsNotNull(instance);
Assert.AreEqual(instance, Singleton<TestBehaviour>.Instance);
yield break;
}
[UnityTest]
public IEnumerator Singleton_ShouldReturnNewInstance_WhenDestroyed()
{
TestBehaviour instance = Singleton<TestBehaviour>.Instance;
Assert.IsTrue(instance);
Assert.IsNotNull(instance);
Object.Destroy(instance);
yield return null;
Assert.IsFalse(instance);
// ReSharper disable once HeuristicUnreachableCode

View File

@ -38,7 +38,7 @@ namespace X10D.Unity.Tests
{
float time = UTime.time;
yield return new WaitForTimeSpan(TimeSpan.FromSeconds(2));
if (System.Math.Abs(UTime.time - (time + 2)) < 1e-2)
if (System.Math.Abs(UTime.time - (time + 2)) < 1e-1)
{
Assert.Pass($"{time + 2} == {UTime.time}");
}