1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 23:25:43 +00:00

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

View File

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

View File

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

View File

@ -1,16 +1,14 @@
using System; using System;
using System.Collections;
using System.Drawing; using System.Drawing;
using NUnit.Framework; using NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Unity.Drawing; using X10D.Unity.Drawing;
namespace X10D.Unity.Tests.Drawing namespace X10D.Unity.Tests.Drawing
{ {
public class PointTests public class PointTests
{ {
[UnityTest] [Test]
public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers() public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var point = new Point(random.Next(), random.Next()); 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.X, vector.x);
Assert.AreEqual(point.Y, vector.y); Assert.AreEqual(point.Y, vector.y);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers() public void ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var point = new Point(random.Next(), random.Next()); 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.X, vector.x);
Assert.AreEqual(point.Y, vector.y); Assert.AreEqual(point.Y, vector.y);
yield break;
} }
} }
} }

View File

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

View File

@ -1,7 +1,5 @@
using System.Collections; using NUnit.Framework;
using NUnit.Framework;
using UnityEngine; using UnityEngine;
using UnityEngine.TestTools;
using X10D.Unity.Drawing; using X10D.Unity.Drawing;
using Random = System.Random; using Random = System.Random;
@ -9,8 +7,8 @@ namespace X10D.Unity.Tests.Drawing
{ {
public class RectIntTests public class RectIntTests
{ {
[UnityTest] [Test]
public IEnumerator ToSystemRectangle_ShouldReturnRectangleF_WithEquivalentMembers() public void ToSystemRectangle_ShouldReturnRectangleF_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next()); 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.y, rectangle.Y);
Assert.AreEqual(rect.width, rectangle.Width); Assert.AreEqual(rect.width, rectangle.Width);
Assert.AreEqual(rect.height, rectangle.Height); Assert.AreEqual(rect.height, rectangle.Height);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers() public void ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next()); 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.y, rectangle.Y);
Assert.AreEqual(rect.width, rectangle.Width); Assert.AreEqual(rect.width, rectangle.Width);
Assert.AreEqual(rect.height, rectangle.Height); 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;
using UnityEngine.TestTools;
using X10D.Core; using X10D.Core;
using X10D.Unity.Drawing; using X10D.Unity.Drawing;
using Random = System.Random; using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Drawing
{ {
public class RectTests public class RectTests
{ {
[UnityTest] [Test]
public IEnumerator ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers() public void ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var rect = new Rect(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle()); 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.y, rectangle.Y, 1e-6f);
Assert.AreEqual(rect.width, rectangle.Width, 1e-6f); Assert.AreEqual(rect.width, rectangle.Width, 1e-6f);
Assert.AreEqual(rect.height, rectangle.Height, 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 NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Core; using X10D.Core;
using X10D.Unity.Drawing; using X10D.Unity.Drawing;
using Random = System.Random; using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Drawing
{ {
public class RectangleFTests public class RectangleFTests
{ {
[UnityTest] [Test]
public IEnumerator ToUnityRect_ShouldReturnRect_WithEquivalentMembers() public void ToUnityRect_ShouldReturnRect_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var rectangle = new RectangleF(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle()); 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.Y, rect.y, 1e-6f);
Assert.AreEqual(rectangle.Width, rect.width, 1e-6f); Assert.AreEqual(rectangle.Width, rect.width, 1e-6f);
Assert.AreEqual(rectangle.Height, rect.height, 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 NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Unity.Drawing; using X10D.Unity.Drawing;
using Random = System.Random; using Random = System.Random;
@ -9,8 +7,8 @@ namespace X10D.Unity.Tests.Drawing
{ {
public class RectangleTests public class RectangleTests
{ {
[UnityTest] [Test]
public IEnumerator ToUnityRect_ShouldReturnRect_WithEquivalentMembers() public void ToUnityRect_ShouldReturnRect_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next()); 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.Y, rect.y);
Assert.AreEqual(rectangle.Width, rect.width); Assert.AreEqual(rectangle.Width, rect.width);
Assert.AreEqual(rectangle.Height, rect.height); Assert.AreEqual(rectangle.Height, rect.height);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToUnityRectInt_ShouldReturnRect_WithEquivalentMembers() public void ToUnityRectInt_ShouldReturnRect_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next()); 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.Y, rect.y);
Assert.AreEqual(rectangle.Width, rect.width); Assert.AreEqual(rectangle.Width, rect.width);
Assert.AreEqual(rectangle.Height, rect.height); Assert.AreEqual(rectangle.Height, rect.height);
yield break;
} }
} }
} }

View File

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

View File

@ -1,16 +1,14 @@
using System; using System;
using System.Collections;
using System.Drawing; using System.Drawing;
using NUnit.Framework; using NUnit.Framework;
using UnityEngine.TestTools;
using X10D.Unity.Drawing; using X10D.Unity.Drawing;
namespace X10D.Unity.Tests.Drawing namespace X10D.Unity.Tests.Drawing
{ {
public class SizeTests public class SizeTests
{ {
[UnityTest] [Test]
public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers() public void ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var size = new Size(random.Next(), random.Next()); 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.Width, vector.x);
Assert.AreEqual(size.Height, vector.y); Assert.AreEqual(size.Height, vector.y);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers() public void ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
var size = new Size(random.Next(), random.Next()); 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.Width, vector.x);
Assert.AreEqual(size.Height, vector.y); 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;
using UnityEngine.TestTools;
using X10D.Core; using X10D.Core;
using X10D.Unity.Numerics; using X10D.Unity.Numerics;
using Random = System.Random; using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Numerics
{ {
public class QuaternionTests public class QuaternionTests
{ {
[UnityTest] [Test]
public IEnumerator ToSystemQuaternion_ShouldReturnQuaternion_WithEqualComponents() public void ToSystemQuaternion_ShouldReturnQuaternion_WithEqualComponents()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -26,12 +24,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(quaternion.y, systemQuaternion.Y, 1e-6f); Assert.AreEqual(quaternion.y, systemQuaternion.Y, 1e-6f);
Assert.AreEqual(quaternion.z, systemQuaternion.Z, 1e-6f); Assert.AreEqual(quaternion.z, systemQuaternion.Z, 1e-6f);
Assert.AreEqual(quaternion.w, systemQuaternion.W, 1e-6f); Assert.AreEqual(quaternion.w, systemQuaternion.W, 1e-6f);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToUnityQuaternion_ShouldReturnQuaternion_WithEqualComponents() public void ToUnityQuaternion_ShouldReturnQuaternion_WithEqualComponents()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -46,8 +42,6 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(quaternion.Y, unityQuaternion.y, 1e-6f); Assert.AreEqual(quaternion.Y, unityQuaternion.y, 1e-6f);
Assert.AreEqual(quaternion.Z, unityQuaternion.z, 1e-6f); Assert.AreEqual(quaternion.Z, unityQuaternion.z, 1e-6f);
Assert.AreEqual(quaternion.W, unityQuaternion.w, 1e-6f); Assert.AreEqual(quaternion.W, unityQuaternion.w, 1e-6f);
yield break;
} }
} }
} }

View File

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

View File

@ -1,7 +1,5 @@
using System.Collections; using NUnit.Framework;
using NUnit.Framework;
using UnityEngine; using UnityEngine;
using UnityEngine.TestTools;
using X10D.Unity.Numerics; using X10D.Unity.Numerics;
using Random = System.Random; using Random = System.Random;
@ -9,20 +7,18 @@ namespace X10D.Unity.Tests.Numerics
{ {
public class Vector2IntTests public class Vector2IntTests
{ {
[UnityTest] [Test]
public IEnumerator Deconstruct_ShouldReturnCorrectValues() public void Deconstruct_ShouldReturnCorrectValues()
{ {
var vector = new Vector2Int(1, 2); var vector = new Vector2Int(1, 2);
(int x, int y) = vector; (int x, int y) = vector;
Assert.AreEqual(1, x); Assert.AreEqual(1, x);
Assert.AreEqual(2, y); Assert.AreEqual(2, y);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToSystemPoint_ShouldReturnPoint_WithEquivalentMembers() public void ToSystemPoint_ShouldReturnPoint_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
int x = random.Next(); int x = random.Next();
@ -33,12 +29,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, point.X); Assert.AreEqual(vector.x, point.X);
Assert.AreEqual(vector.y, point.Y); Assert.AreEqual(vector.y, point.Y);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToSystemSize_ShouldReturnSize_WithEquivalentMembers() public void ToSystemSize_ShouldReturnSize_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
int x = random.Next(); int x = random.Next();
@ -49,12 +43,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, point.Width); Assert.AreEqual(vector.x, point.Width);
Assert.AreEqual(vector.y, point.Height); Assert.AreEqual(vector.y, point.Height);
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector() public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{ {
Assert.AreEqual(Vector2Int.up, Vector2Int.one.WithX(0)); Assert.AreEqual(Vector2Int.up, Vector2Int.one.WithX(0));
Assert.AreEqual(Vector2Int.zero, Vector2Int.zero.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.zero.WithX(1));
Assert.AreEqual(Vector2Int.right, Vector2Int.right.WithX(1)); Assert.AreEqual(Vector2Int.right, Vector2Int.right.WithX(1));
Assert.AreEqual(Vector2Int.one, Vector2Int.up.WithX(1)); Assert.AreEqual(Vector2Int.one, Vector2Int.up.WithX(1));
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector() public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{ {
Assert.AreEqual(Vector2Int.right, Vector2Int.one.WithY(0)); Assert.AreEqual(Vector2Int.right, Vector2Int.one.WithY(0));
Assert.AreEqual(Vector2Int.zero, Vector2Int.zero.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.up, Vector2Int.zero.WithY(1));
Assert.AreEqual(Vector2Int.one, Vector2Int.right.WithY(1)); Assert.AreEqual(Vector2Int.one, Vector2Int.right.WithY(1));
Assert.AreEqual(Vector2Int.up, Vector2Int.up.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;
using UnityEngine.TestTools;
using X10D.Core; using X10D.Core;
using X10D.Unity.Numerics; using X10D.Unity.Numerics;
using Random = System.Random; using Random = System.Random;
@ -10,44 +8,38 @@ namespace X10D.Unity.Tests.Numerics
{ {
public class Vector2Tests public class Vector2Tests
{ {
[UnityTest] [Test]
public IEnumerator Deconstruct_ShouldReturnCorrectValues() public void Deconstruct_ShouldReturnCorrectValues()
{ {
var vector = new Vector2(1, 2); var vector = new Vector2(1, 2);
(float x, float y) = vector; (float x, float y) = vector;
Assert.AreEqual(1, x); Assert.AreEqual(1, x);
Assert.AreEqual(2, y); Assert.AreEqual(2, y);
yield break;
} }
[UnityTest] [Test]
public IEnumerator Round_ShouldRoundToNearestInteger_GivenNoParameters() public void Round_ShouldRoundToNearestInteger_GivenNoParameters()
{ {
var vector = new Vector2(1.5f, 2.6f); var vector = new Vector2(1.5f, 2.6f);
var rounded = vector.Round(); var rounded = vector.Round();
Assert.AreEqual(2, rounded.x); Assert.AreEqual(2, rounded.x);
Assert.AreEqual(3, rounded.y); Assert.AreEqual(3, rounded.y);
yield break;
} }
[UnityTest] [Test]
public IEnumerator Round_ShouldRoundToNearest10_GivenPrecision10() public void Round_ShouldRoundToNearest10_GivenPrecision10()
{ {
var vector = new Vector2(1.5f, 25.2f); var vector = new Vector2(1.5f, 25.2f);
var rounded = vector.Round(10); var rounded = vector.Round(10);
Assert.AreEqual(0, rounded.x); Assert.AreEqual(0, rounded.x);
Assert.AreEqual(30, rounded.y); Assert.AreEqual(30, rounded.y);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToSystemPointF_ShouldReturnPoint_WithEquivalentMembers() public void ToSystemPointF_ShouldReturnPoint_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -58,12 +50,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, point.X, 1e-6f); Assert.AreEqual(vector.x, point.X, 1e-6f);
Assert.AreEqual(vector.y, point.Y, 1e-6f); Assert.AreEqual(vector.y, point.Y, 1e-6f);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToSystemSizeF_ShouldReturnSize_WithEquivalentMembers() public void ToSystemSizeF_ShouldReturnSize_WithEquivalentMembers()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -74,12 +64,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, point.Width, 1e-6f); Assert.AreEqual(vector.x, point.Width, 1e-6f);
Assert.AreEqual(vector.y, point.Height, 1e-6f); Assert.AreEqual(vector.y, point.Height, 1e-6f);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents() public void ToSystemVector_ShouldReturnVector_WithEqualComponents()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -91,12 +79,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.magnitude, systemVector.Length(), 1e-6f); Assert.AreEqual(vector.magnitude, systemVector.Length(), 1e-6f);
Assert.AreEqual(vector.x, systemVector.X, 1e-6f); Assert.AreEqual(vector.x, systemVector.X, 1e-6f);
Assert.AreEqual(vector.y, systemVector.Y, 1e-6f); Assert.AreEqual(vector.y, systemVector.Y, 1e-6f);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToUnityVector_ShouldReturnVector_WithEqualComponents() public void ToUnityVector_ShouldReturnVector_WithEqualComponents()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -108,12 +94,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.Length(), unityVector.magnitude, 1e-6f); Assert.AreEqual(vector.Length(), unityVector.magnitude, 1e-6f);
Assert.AreEqual(vector.X, unityVector.x, 1e-6f); Assert.AreEqual(vector.X, unityVector.x, 1e-6f);
Assert.AreEqual(vector.Y, unityVector.y, 1e-6f); Assert.AreEqual(vector.Y, unityVector.y, 1e-6f);
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector() public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{ {
Assert.AreEqual(Vector2.up, Vector2.one.WithX(0)); Assert.AreEqual(Vector2.up, Vector2.one.WithX(0));
Assert.AreEqual(Vector2.zero, Vector2.zero.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.zero.WithX(1));
Assert.AreEqual(Vector2.right, Vector2.right.WithX(1)); Assert.AreEqual(Vector2.right, Vector2.right.WithX(1));
Assert.AreEqual(Vector2.one, Vector2.up.WithX(1)); Assert.AreEqual(Vector2.one, Vector2.up.WithX(1));
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector() public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{ {
Assert.AreEqual(Vector2.right, Vector2.one.WithY(0)); Assert.AreEqual(Vector2.right, Vector2.one.WithY(0));
Assert.AreEqual(Vector2.zero, Vector2.zero.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.up, Vector2.zero.WithY(1));
Assert.AreEqual(Vector2.one, Vector2.right.WithY(1)); Assert.AreEqual(Vector2.one, Vector2.right.WithY(1));
Assert.AreEqual(Vector2.up, Vector2.up.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;
using UnityEngine.TestTools;
using X10D.Unity.Numerics; using X10D.Unity.Numerics;
namespace X10D.Unity.Tests.Numerics namespace X10D.Unity.Tests.Numerics
{ {
public class Vector3IntTests public class Vector3IntTests
{ {
[UnityTest] [Test]
public IEnumerator Deconstruct_ShouldReturnCorrectValues() public void Deconstruct_ShouldReturnCorrectValues()
{ {
var vector = new Vector3Int(1, 2, 3); var vector = new Vector3Int(1, 2, 3);
(float x, float y, float z) = vector; (float x, float y, float z) = vector;
@ -17,12 +15,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(1, x); Assert.AreEqual(1, x);
Assert.AreEqual(2, y); Assert.AreEqual(2, y);
Assert.AreEqual(3, z); Assert.AreEqual(3, z);
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector() public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{ {
Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.one.WithX(0)); Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.one.WithX(0));
Assert.AreEqual(Vector3Int.zero, Vector3Int.zero.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(Vector3Int.right, Vector3Int.right.WithX(1));
Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.up.WithX(1)); Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.up.WithX(1));
Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.forward.WithX(1)); Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.forward.WithX(1));
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector() public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{ {
Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.one.WithY(0)); Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.one.WithY(0));
Assert.AreEqual(Vector3Int.zero, Vector3Int.zero.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(new Vector3Int(1, 1, 0), Vector3Int.right.WithY(1));
Assert.AreEqual(Vector3Int.up, Vector3Int.up.WithY(1)); Assert.AreEqual(Vector3Int.up, Vector3Int.up.WithY(1));
Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.forward.WithY(1)); Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.forward.WithY(1));
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithZ_ShouldReturnVectorWithNewZ_GivenVector() public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
{ {
Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.one.WithZ(0)); Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.one.WithZ(0));
Assert.AreEqual(Vector3Int.zero, Vector3Int.zero.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(1, 0, 1), Vector3Int.right.WithZ(1));
Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.up.WithZ(1)); Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.up.WithZ(1));
Assert.AreEqual(Vector3Int.forward, Vector3Int.forward.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;
using UnityEngine.TestTools;
using X10D.Core; using X10D.Core;
using X10D.Unity.Numerics; using X10D.Unity.Numerics;
using Random = System.Random; using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Numerics
{ {
public class Vector3Tests public class Vector3Tests
{ {
[UnityTest] [Test]
public IEnumerator Deconstruct_ShouldReturnCorrectValues() public void Deconstruct_ShouldReturnCorrectValues()
{ {
var vector = new Vector3(1, 2, 3); var vector = new Vector3(1, 2, 3);
(float x, float y, float z) = vector; (float x, float y, float z) = vector;
@ -19,12 +17,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(1, x); Assert.AreEqual(1, x);
Assert.AreEqual(2, y); Assert.AreEqual(2, y);
Assert.AreEqual(3, z); Assert.AreEqual(3, z);
yield break;
} }
[UnityTest] [Test]
public IEnumerator Round_ShouldRoundToNearestInteger_GivenNoParameters() public void Round_ShouldRoundToNearestInteger_GivenNoParameters()
{ {
var vector = new Vector3(1.5f, 2.6f, -5.2f); var vector = new Vector3(1.5f, 2.6f, -5.2f);
var rounded = vector.Round(); var rounded = vector.Round();
@ -32,12 +28,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(2, rounded.x); Assert.AreEqual(2, rounded.x);
Assert.AreEqual(3, rounded.y); Assert.AreEqual(3, rounded.y);
Assert.AreEqual(-5, rounded.z); Assert.AreEqual(-5, rounded.z);
yield break;
} }
[UnityTest] [Test]
public IEnumerator Round_ShouldRoundToNearest10_GivenPrecision10() public void Round_ShouldRoundToNearest10_GivenPrecision10()
{ {
var vector = new Vector3(1.5f, 25.2f, -12.5f); var vector = new Vector3(1.5f, 25.2f, -12.5f);
var rounded = vector.Round(10); var rounded = vector.Round(10);
@ -45,12 +39,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(0, rounded.x); Assert.AreEqual(0, rounded.x);
Assert.AreEqual(30, rounded.y); Assert.AreEqual(30, rounded.y);
Assert.AreEqual(-10, rounded.z); Assert.AreEqual(-10, rounded.z);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents() public void ToSystemVector_ShouldReturnVector_WithEqualComponents()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -64,12 +56,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.x, systemVector.X, 1e-6f); Assert.AreEqual(vector.x, systemVector.X, 1e-6f);
Assert.AreEqual(vector.y, systemVector.Y, 1e-6f); Assert.AreEqual(vector.y, systemVector.Y, 1e-6f);
Assert.AreEqual(vector.z, systemVector.Z, 1e-6f); Assert.AreEqual(vector.z, systemVector.Z, 1e-6f);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToUnityVector_ShouldReturnVector_WithEqualComponents() public void ToUnityVector_ShouldReturnVector_WithEqualComponents()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -83,12 +73,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.X, unityVector.x, 1e-6f); Assert.AreEqual(vector.X, unityVector.x, 1e-6f);
Assert.AreEqual(vector.Y, unityVector.y, 1e-6f); Assert.AreEqual(vector.Y, unityVector.y, 1e-6f);
Assert.AreEqual(vector.Z, unityVector.z, 1e-6f); Assert.AreEqual(vector.Z, unityVector.z, 1e-6f);
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector() public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{ {
Assert.AreEqual(new Vector3(0, 1, 1), Vector3.one.WithX(0)); Assert.AreEqual(new Vector3(0, 1, 1), Vector3.one.WithX(0));
Assert.AreEqual(Vector3.zero, Vector3.zero.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(Vector3.right, Vector3.right.WithX(1));
Assert.AreEqual(new Vector3(1, 1, 0), Vector3.up.WithX(1)); Assert.AreEqual(new Vector3(1, 1, 0), Vector3.up.WithX(1));
Assert.AreEqual(new Vector3(1, 0, 1), Vector3.forward.WithX(1)); Assert.AreEqual(new Vector3(1, 0, 1), Vector3.forward.WithX(1));
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector() public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{ {
Assert.AreEqual(new Vector3(1, 0, 1), Vector3.one.WithY(0)); Assert.AreEqual(new Vector3(1, 0, 1), Vector3.one.WithY(0));
Assert.AreEqual(Vector3.zero, Vector3.zero.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(new Vector3(1, 1, 0), Vector3.right.WithY(1));
Assert.AreEqual(Vector3.up, Vector3.up.WithY(1)); Assert.AreEqual(Vector3.up, Vector3.up.WithY(1));
Assert.AreEqual(new Vector3(0, 1, 1), Vector3.forward.WithY(1)); Assert.AreEqual(new Vector3(0, 1, 1), Vector3.forward.WithY(1));
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithZ_ShouldReturnVectorWithNewZ_GivenVector() public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
{ {
Assert.AreEqual(new Vector3(1, 1, 0), Vector3.one.WithZ(0)); Assert.AreEqual(new Vector3(1, 1, 0), Vector3.one.WithZ(0));
Assert.AreEqual(Vector3.zero, Vector3.zero.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(1, 0, 1), Vector3.right.WithZ(1));
Assert.AreEqual(new Vector3(0, 1, 1), Vector3.up.WithZ(1)); Assert.AreEqual(new Vector3(0, 1, 1), Vector3.up.WithZ(1));
Assert.AreEqual(Vector3.forward, Vector3.forward.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;
using UnityEngine.TestTools;
using X10D.Core; using X10D.Core;
using X10D.Unity.Numerics; using X10D.Unity.Numerics;
using Random = System.Random; using Random = System.Random;
@ -10,8 +8,8 @@ namespace X10D.Unity.Tests.Numerics
{ {
public class Vector4Tests public class Vector4Tests
{ {
[UnityTest] [Test]
public IEnumerator Deconstruct_ShouldReturnCorrectValues() public void Deconstruct_ShouldReturnCorrectValues()
{ {
var vector = new Vector4(1, 2, 3, 4); var vector = new Vector4(1, 2, 3, 4);
(float x, float y, float z, float w) = vector; (float x, float y, float z, float w) = vector;
@ -20,12 +18,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(2, y); Assert.AreEqual(2, y);
Assert.AreEqual(3, z); Assert.AreEqual(3, z);
Assert.AreEqual(4, w); Assert.AreEqual(4, w);
yield break;
} }
[UnityTest] [Test]
public IEnumerator Round_ShouldRoundToNearestInteger_GivenNoParameters() public void Round_ShouldRoundToNearestInteger_GivenNoParameters()
{ {
var vector = new Vector4(1.5f, 2.6f, -5.2f, 0.3f); var vector = new Vector4(1.5f, 2.6f, -5.2f, 0.3f);
var rounded = vector.Round(); var rounded = vector.Round();
@ -34,12 +30,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(3, rounded.y); Assert.AreEqual(3, rounded.y);
Assert.AreEqual(-5, rounded.z); Assert.AreEqual(-5, rounded.z);
Assert.AreEqual(0, rounded.w); Assert.AreEqual(0, rounded.w);
yield break;
} }
[UnityTest] [Test]
public IEnumerator Round_ShouldRoundToNearest10_GivenPrecision10() public void Round_ShouldRoundToNearest10_GivenPrecision10()
{ {
var vector = new Vector4(1.5f, 25.2f, -12.5f, 101.2f); var vector = new Vector4(1.5f, 25.2f, -12.5f, 101.2f);
var rounded = vector.Round(10); var rounded = vector.Round(10);
@ -48,12 +42,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(30, rounded.y); Assert.AreEqual(30, rounded.y);
Assert.AreEqual(-10, rounded.z); Assert.AreEqual(-10, rounded.z);
Assert.AreEqual(100, rounded.w); Assert.AreEqual(100, rounded.w);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents() public void ToSystemVector_ShouldReturnVector_WithEqualComponents()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -69,12 +61,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.y, systemVector.Y, 1e-6f); Assert.AreEqual(vector.y, systemVector.Y, 1e-6f);
Assert.AreEqual(vector.z, systemVector.Z, 1e-6f); Assert.AreEqual(vector.z, systemVector.Z, 1e-6f);
Assert.AreEqual(vector.w, systemVector.W, 1e-6f); Assert.AreEqual(vector.w, systemVector.W, 1e-6f);
yield break;
} }
[UnityTest] [Test]
public IEnumerator ToUnityVector_ShouldReturnVector_WithEqualComponents() public void ToUnityVector_ShouldReturnVector_WithEqualComponents()
{ {
var random = new Random(); var random = new Random();
float x = random.NextSingle(); float x = random.NextSingle();
@ -90,12 +80,10 @@ namespace X10D.Unity.Tests.Numerics
Assert.AreEqual(vector.Y, unityVector.y, 1e-6f); Assert.AreEqual(vector.Y, unityVector.y, 1e-6f);
Assert.AreEqual(vector.Z, unityVector.z, 1e-6f); Assert.AreEqual(vector.Z, unityVector.z, 1e-6f);
Assert.AreEqual(vector.W, unityVector.w, 1e-6f); Assert.AreEqual(vector.W, unityVector.w, 1e-6f);
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithW_ShouldReturnVectorWithNewW_GivenVector() public void WithW_ShouldReturnVectorWithNewW_GivenVector()
{ {
Assert.AreEqual(new Vector4(1, 1, 1, 0), Vector4.one.WithW(0)); Assert.AreEqual(new Vector4(1, 1, 1, 0), Vector4.one.WithW(0));
Assert.AreEqual(Vector4.zero, Vector4.zero.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(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, 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)); Assert.AreEqual(new Vector4(0, 0, 1, 1), new Vector4(0, 0, 1, 0).WithW(1));
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithX_ShouldReturnVectorWithNewX_GivenVector() public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{ {
Assert.AreEqual(new Vector4(0, 1, 1, 1), Vector4.one.WithX(0)); Assert.AreEqual(new Vector4(0, 1, 1, 1), Vector4.one.WithX(0));
Assert.AreEqual(Vector4.zero, Vector4.zero.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, 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, 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)); Assert.AreEqual(new Vector4(1, 0, 1, 0), new Vector4(0, 0, 1, 0).WithX(1));
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithY_ShouldReturnVectorWithNewY_GivenVector() public void WithY_ShouldReturnVectorWithNewY_GivenVector()
{ {
Assert.AreEqual(new Vector4(1, 0, 1, 1), Vector4.one.WithY(0)); Assert.AreEqual(new Vector4(1, 0, 1, 1), Vector4.one.WithY(0));
Assert.AreEqual(Vector4.zero, Vector4.zero.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(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, 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)); Assert.AreEqual(new Vector4(0, 1, 1, 0), new Vector4(0, 0, 1, 0).WithY(1));
yield break;
} }
[UnityTest] [Test]
public IEnumerator WithZ_ShouldReturnVectorWithNewZ_GivenVector() public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
{ {
Assert.AreEqual(new Vector4(1, 1, 0, 1), Vector4.one.WithZ(0)); Assert.AreEqual(new Vector4(1, 1, 0, 1), Vector4.one.WithZ(0));
Assert.AreEqual(Vector4.zero, Vector4.zero.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(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, 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)); 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 public class SingletonTests
{ {
[UnityTest] [Test]
public IEnumerator Singleton_ShouldReturnNewInstance_WhenNoInstanceExists() public void Singleton_ShouldReturnNewInstance_WhenNoInstanceExists()
{ {
TestBehaviour instance = Singleton<TestBehaviour>.Instance; TestBehaviour instance = Singleton<TestBehaviour>.Instance;
Assert.IsTrue(instance); Assert.IsNotNull(instance);
Assert.IsTrue(instance.Flag); Assert.IsTrue(instance.Flag);
yield break;
} }
[UnityTest] [Test]
public IEnumerator Singleton_ShouldReturnSameInstance_WhenAccessedTwice() public void Singleton_ShouldReturnSameInstance_WhenAccessedTwice()
{ {
TestBehaviour instance = Singleton<TestBehaviour>.Instance; TestBehaviour instance = Singleton<TestBehaviour>.Instance;
Assert.IsTrue(instance); Assert.IsNotNull(instance);
Assert.AreEqual(instance, Singleton<TestBehaviour>.Instance); Assert.AreEqual(instance, Singleton<TestBehaviour>.Instance);
yield break;
} }
[UnityTest] [UnityTest]
public IEnumerator Singleton_ShouldReturnNewInstance_WhenDestroyed() public IEnumerator Singleton_ShouldReturnNewInstance_WhenDestroyed()
{ {
TestBehaviour instance = Singleton<TestBehaviour>.Instance; TestBehaviour instance = Singleton<TestBehaviour>.Instance;
Assert.IsTrue(instance); Assert.IsNotNull(instance);
Object.Destroy(instance); Object.Destroy(instance);
yield return null; yield return null;
Assert.IsFalse(instance); Assert.IsFalse(instance);
// ReSharper disable once HeuristicUnreachableCode // ReSharper disable once HeuristicUnreachableCode

View File

@ -38,7 +38,7 @@ namespace X10D.Unity.Tests
{ {
float time = UTime.time; float time = UTime.time;
yield return new WaitForTimeSpan(TimeSpan.FromSeconds(2)); 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}"); Assert.Pass($"{time + 2} == {UTime.time}");
} }