mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
test: use NUnit constraint API in X10D.Unity.Tests (#76)
This commit is contained in:
parent
744f5e906b
commit
fcdcf54aa3
@ -20,8 +20,8 @@ namespace X10D.Unity.Tests
|
|||||||
child.AddComponent<Rigidbody>();
|
child.AddComponent<Rigidbody>();
|
||||||
|
|
||||||
Rigidbody[] components = rigidbody.GetComponentsInChildrenOnly<Rigidbody>();
|
Rigidbody[] components = rigidbody.GetComponentsInChildrenOnly<Rigidbody>();
|
||||||
Assert.AreEqual(1, components.Length);
|
Assert.That(components.Length, Is.EqualTo(1));
|
||||||
Assert.AreEqual(components[0].gameObject, child);
|
Assert.That(child, Is.EqualTo(components[0].gameObject));
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,15 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
byte a, r, g, b;
|
byte a, r, g, b;
|
||||||
|
|
||||||
(r, g, b) = White;
|
(r, g, b) = White;
|
||||||
Assert.AreEqual(255, r);
|
Assert.That(r, Is.EqualTo(255));
|
||||||
Assert.AreEqual(255, g);
|
Assert.That(g, Is.EqualTo(255));
|
||||||
Assert.AreEqual(255, b);
|
Assert.That(b, Is.EqualTo(255));
|
||||||
|
|
||||||
(a, r, g, b) = Yellow;
|
(a, r, g, b) = Yellow;
|
||||||
Assert.AreEqual(255, a);
|
Assert.That(a, Is.EqualTo(255));
|
||||||
Assert.AreEqual(255, r);
|
Assert.That(r, Is.EqualTo(255));
|
||||||
Assert.AreEqual(255, g);
|
Assert.That(g, Is.EqualTo(255));
|
||||||
Assert.AreEqual(0, b);
|
Assert.That(b, Is.EqualTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -38,30 +38,30 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
{
|
{
|
||||||
// I know it's just casting... but aim for 100% coverage babyyyy
|
// I know it's just casting... but aim for 100% coverage babyyyy
|
||||||
|
|
||||||
Assert.AreEqual(ConsoleColor.Red, ((Color32)Color.red).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.red).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Red));
|
||||||
Assert.AreEqual(ConsoleColor.Green, ((Color32)Color.green).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.green).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Green));
|
||||||
Assert.AreEqual(ConsoleColor.Blue, ((Color32)Color.blue).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.blue).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Blue));
|
||||||
Assert.AreEqual(ConsoleColor.White, ((Color32)Color.white).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.white).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.White));
|
||||||
Assert.AreEqual(ConsoleColor.Black, ((Color32)Color.black).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.black).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Black));
|
||||||
Assert.AreEqual(ConsoleColor.Yellow, ((Color32)Color.yellow).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.yellow).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Yellow));
|
||||||
Assert.AreEqual(ConsoleColor.Cyan, ((Color32)Color.cyan).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.cyan).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Cyan));
|
||||||
Assert.AreEqual(ConsoleColor.Magenta, ((Color32)Color.magenta).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.magenta).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Magenta));
|
||||||
Assert.AreEqual(ConsoleColor.Gray, ((Color32)Color.gray).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.gray).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Gray));
|
||||||
Assert.AreEqual(ConsoleColor.Gray, ((Color32)Color.grey).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.grey).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Gray));
|
||||||
Assert.AreEqual(ConsoleColor.Black, ((Color32)Color.clear).GetClosestConsoleColor());
|
Assert.That(((Color32)Color.clear).GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Black));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Inverted_ShouldReturnInvertedColor()
|
public void Inverted_ShouldReturnInvertedColor()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(White, Black.Inverted());
|
Assert.That(Black.Inverted(), Is.EqualTo(White));
|
||||||
Assert.AreEqual(Black, White.Inverted());
|
Assert.That(White.Inverted(), Is.EqualTo(Black));
|
||||||
Assert.AreEqual(Red, Cyan.Inverted());
|
Assert.That(Cyan.Inverted(), Is.EqualTo(Red));
|
||||||
Assert.AreEqual(Cyan, Red.Inverted());
|
Assert.That(Red.Inverted(), Is.EqualTo(Cyan));
|
||||||
Assert.AreEqual(Green, Magenta.Inverted());
|
Assert.That(Magenta.Inverted(), Is.EqualTo(Green));
|
||||||
Assert.AreEqual(Magenta, Green.Inverted());
|
Assert.That(Green.Inverted(), Is.EqualTo(Magenta));
|
||||||
Assert.AreEqual(Yellow, Blue.Inverted());
|
Assert.That(Blue.Inverted(), Is.EqualTo(Yellow));
|
||||||
Assert.AreEqual(Blue, Yellow.Inverted());
|
Assert.That(Yellow.Inverted(), Is.EqualTo(Blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -70,7 +70,7 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
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.That(actual, Is.EqualTo(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -79,7 +79,7 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
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.That(actual, Is.EqualTo(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -88,36 +88,36 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
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.That(actual, Is.EqualTo(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void 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.That(White.WithA(0), Is.EqualTo(transparent));
|
||||||
Assert.AreEqual(transparent, transparent.WithA(0));
|
Assert.That(transparent.WithA(0), Is.EqualTo(transparent));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithB0_ShouldReturnYellow_GivenWhite()
|
public void WithB0_ShouldReturnYellow_GivenWhite()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Yellow, White.WithB(0));
|
Assert.That(White.WithB(0), Is.EqualTo(Yellow));
|
||||||
Assert.AreEqual(Yellow, Yellow.WithB(0));
|
Assert.That(Yellow.WithB(0), Is.EqualTo(Yellow));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithG0_ShouldReturnMagenta_GivenWhite()
|
public void WithG0_ShouldReturnMagenta_GivenWhite()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Magenta, White.WithG(0));
|
Assert.That(White.WithG(0), Is.EqualTo(Magenta));
|
||||||
Assert.AreEqual(Magenta, Magenta.WithG(0));
|
Assert.That(Magenta.WithG(0), Is.EqualTo(Magenta));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithR0_ShouldReturnCyan_GivenWhite()
|
public void WithR0_ShouldReturnCyan_GivenWhite()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Cyan, White.WithR(0));
|
Assert.That(White.WithR(0), Is.EqualTo(Cyan));
|
||||||
Assert.AreEqual(Cyan, Cyan.WithR(0));
|
Assert.That(Cyan.WithR(0), Is.EqualTo(Cyan));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,44 +22,44 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
float a, r, g, b;
|
float a, r, g, b;
|
||||||
|
|
||||||
(r, g, b) = White;
|
(r, g, b) = White;
|
||||||
Assert.AreEqual(1.0f, r);
|
Assert.That(r, Is.EqualTo(1.0f));
|
||||||
Assert.AreEqual(1.0f, g);
|
Assert.That(g, Is.EqualTo(1.0f));
|
||||||
Assert.AreEqual(1.0f, b);
|
Assert.That(b, Is.EqualTo(1.0f));
|
||||||
|
|
||||||
(a, r, g, b) = Yellow;
|
(a, r, g, b) = Yellow;
|
||||||
Assert.AreEqual(1.0f, a);
|
Assert.That(a, Is.EqualTo(1.0f));
|
||||||
Assert.AreEqual(1.0f, r);
|
Assert.That(r, Is.EqualTo(1.0f));
|
||||||
Assert.AreEqual(1.0f, g);
|
Assert.That(g, Is.EqualTo(1.0f));
|
||||||
Assert.AreEqual(0.0f, b);
|
Assert.That(b, Is.EqualTo(0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor()
|
public void GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(ConsoleColor.Red, Color.red.GetClosestConsoleColor());
|
Assert.That(Color.red.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Red));
|
||||||
Assert.AreEqual(ConsoleColor.Green, Color.green.GetClosestConsoleColor());
|
Assert.That(Color.green.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Green));
|
||||||
Assert.AreEqual(ConsoleColor.Blue, Color.blue.GetClosestConsoleColor());
|
Assert.That(Color.blue.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Blue));
|
||||||
Assert.AreEqual(ConsoleColor.White, Color.white.GetClosestConsoleColor());
|
Assert.That(Color.white.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.White));
|
||||||
Assert.AreEqual(ConsoleColor.Black, Color.black.GetClosestConsoleColor());
|
Assert.That(Color.black.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Black));
|
||||||
Assert.AreEqual(ConsoleColor.Yellow, Color.yellow.GetClosestConsoleColor());
|
Assert.That(Color.yellow.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Yellow));
|
||||||
Assert.AreEqual(ConsoleColor.Cyan, Color.cyan.GetClosestConsoleColor());
|
Assert.That(Color.cyan.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Cyan));
|
||||||
Assert.AreEqual(ConsoleColor.Magenta, Color.magenta.GetClosestConsoleColor());
|
Assert.That(Color.magenta.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Magenta));
|
||||||
Assert.AreEqual(ConsoleColor.Gray, Color.gray.GetClosestConsoleColor());
|
Assert.That(Color.gray.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Gray));
|
||||||
Assert.AreEqual(ConsoleColor.Gray, Color.grey.GetClosestConsoleColor());
|
Assert.That(Color.grey.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Gray));
|
||||||
Assert.AreEqual(ConsoleColor.Black, Color.clear.GetClosestConsoleColor());
|
Assert.That(Color.clear.GetClosestConsoleColor(), Is.EqualTo(ConsoleColor.Black));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Inverted_ShouldReturnInvertedColor()
|
public void Inverted_ShouldReturnInvertedColor()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(White, Black.Inverted());
|
Assert.That(Black.Inverted(), Is.EqualTo(White));
|
||||||
Assert.AreEqual(Black, White.Inverted());
|
Assert.That(White.Inverted(), Is.EqualTo(Black));
|
||||||
Assert.AreEqual(Red, Cyan.Inverted());
|
Assert.That(Cyan.Inverted(), Is.EqualTo(Red));
|
||||||
Assert.AreEqual(Cyan, Red.Inverted());
|
Assert.That(Red.Inverted(), Is.EqualTo(Cyan));
|
||||||
Assert.AreEqual(Green, Magenta.Inverted());
|
Assert.That(Magenta.Inverted(), Is.EqualTo(Green));
|
||||||
Assert.AreEqual(Magenta, Green.Inverted());
|
Assert.That(Green.Inverted(), Is.EqualTo(Magenta));
|
||||||
Assert.AreEqual(Yellow, Blue.Inverted());
|
Assert.That(Blue.Inverted(), Is.EqualTo(Yellow));
|
||||||
Assert.AreEqual(Blue, Yellow.Inverted());
|
Assert.That(Yellow.Inverted(), Is.EqualTo(Blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -68,7 +68,7 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
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.That(actual, Is.EqualTo(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -77,7 +77,7 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
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.That(actual, Is.EqualTo(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -86,36 +86,36 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
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.That(actual, Is.EqualTo(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void 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.That(White.WithA(0), Is.EqualTo(transparent));
|
||||||
Assert.AreEqual(transparent, transparent.WithA(0));
|
Assert.That(transparent.WithA(0), Is.EqualTo(transparent));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithB0_ShouldReturnYellow_GivenWhite()
|
public void WithB0_ShouldReturnYellow_GivenWhite()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Yellow, White.WithB(0));
|
Assert.That(White.WithB(0), Is.EqualTo(Yellow));
|
||||||
Assert.AreEqual(Yellow, Yellow.WithB(0));
|
Assert.That(Yellow.WithB(0), Is.EqualTo(Yellow));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithG0_ShouldReturnMagenta_GivenWhite()
|
public void WithG0_ShouldReturnMagenta_GivenWhite()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Magenta, White.WithG(0));
|
Assert.That(White.WithG(0), Is.EqualTo(Magenta));
|
||||||
Assert.AreEqual(Magenta, Magenta.WithG(0));
|
Assert.That(Magenta.WithG(0), Is.EqualTo(Magenta));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithR0_ShouldReturnCyan_GivenWhite()
|
public void WithR0_ShouldReturnCyan_GivenWhite()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Cyan, White.WithR(0));
|
Assert.That(White.WithR(0), Is.EqualTo(Cyan));
|
||||||
Assert.AreEqual(Cyan, Cyan.WithR(0));
|
Assert.That(Cyan.WithR(0), Is.EqualTo(Cyan));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var point = new PointF(random.NextSingle(), random.NextSingle());
|
var point = new PointF(random.NextSingle(), random.NextSingle());
|
||||||
var vector = point.ToUnityVector2();
|
var vector = point.ToUnityVector2();
|
||||||
|
|
||||||
Assert.AreEqual(point.X, vector.x, 1e-6f);
|
Assert.That(vector.x, Is.EqualTo(point.X).Within(1e-6f));
|
||||||
Assert.AreEqual(point.Y, vector.y, 1e-6f);
|
Assert.That(vector.y, Is.EqualTo(point.Y).Within(1e-6f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var point = new Point(random.Next(), random.Next());
|
var point = new Point(random.Next(), random.Next());
|
||||||
var vector = point.ToUnityVector2();
|
var vector = point.ToUnityVector2();
|
||||||
|
|
||||||
Assert.AreEqual(point.X, vector.x);
|
Assert.That(vector.x, Is.EqualTo(point.X));
|
||||||
Assert.AreEqual(point.Y, vector.y);
|
Assert.That(vector.y, Is.EqualTo(point.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -25,8 +25,8 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var point = new Point(random.Next(), random.Next());
|
var point = new Point(random.Next(), random.Next());
|
||||||
var vector = point.ToUnityVector2Int();
|
var vector = point.ToUnityVector2Int();
|
||||||
|
|
||||||
Assert.AreEqual(point.X, vector.x);
|
Assert.That(vector.x, Is.EqualTo(point.X));
|
||||||
Assert.AreEqual(point.Y, vector.y);
|
Assert.That(vector.y, Is.EqualTo(point.Y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
{
|
{
|
||||||
var random = new Random(1234);
|
var random = new Random(1234);
|
||||||
var color = random.NextColorArgb();
|
var color = random.NextColorArgb();
|
||||||
Assert.AreEqual(0.373868465f, color.r, 1e-6f);
|
Assert.That(color.r, Is.EqualTo(0.373868465f).Within(1e-6f));
|
||||||
Assert.AreEqual(0.391597569f, color.g, 1e-6f);
|
Assert.That(color.g, Is.EqualTo(0.391597569f).Within(1e-6f));
|
||||||
Assert.AreEqual(0.675019085f, color.b, 1e-6f);
|
Assert.That(color.b, Is.EqualTo(0.675019085f).Within(1e-6f));
|
||||||
Assert.AreEqual(0.234300315f, color.a, 1e-6f);
|
Assert.That(color.a, Is.EqualTo(0.234300315f).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -32,7 +32,7 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
public void 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.That(random.NextColor32Argb(), Is.EqualTo(new Color32(21, 21, 229, 51)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -47,10 +47,10 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
{
|
{
|
||||||
var random = new Random(1234);
|
var random = new Random(1234);
|
||||||
var color = random.NextColorRgb();
|
var color = random.NextColorRgb();
|
||||||
Assert.AreEqual(0.234300315f, color.r, 1e-6f);
|
Assert.That(color.r, Is.EqualTo(0.234300315f).Within(1e-6f));
|
||||||
Assert.AreEqual(0.373868465f, color.g, 1e-6f);
|
Assert.That(color.g, Is.EqualTo(0.373868465f).Within(1e-6f));
|
||||||
Assert.AreEqual(0.391597569f, color.b, 1e-6f);
|
Assert.That(color.b, Is.EqualTo(0.391597569f).Within(1e-6f));
|
||||||
Assert.AreEqual(1, color.a, 1e-6f);
|
Assert.That(color.a, Is.EqualTo(1).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -64,7 +64,7 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
public void 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.That(random.NextColor32Rgb(), Is.EqualTo(new Color32(21, 21, 229, 255)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -14,10 +14,10 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next());
|
var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next());
|
||||||
var rectangle = rect.ToSystemRectangle();
|
var rectangle = rect.ToSystemRectangle();
|
||||||
|
|
||||||
Assert.AreEqual(rect.x, rectangle.X);
|
Assert.That(rectangle.X, Is.EqualTo(rect.x));
|
||||||
Assert.AreEqual(rect.y, rectangle.Y);
|
Assert.That(rectangle.Y, Is.EqualTo(rect.y));
|
||||||
Assert.AreEqual(rect.width, rectangle.Width);
|
Assert.That(rectangle.Width, Is.EqualTo(rect.width));
|
||||||
Assert.AreEqual(rect.height, rectangle.Height);
|
Assert.That(rectangle.Height, Is.EqualTo(rect.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -27,10 +27,10 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next());
|
var rect = new RectInt(random.Next(), random.Next(), random.Next(), random.Next());
|
||||||
var rectangle = rect.ToSystemRectangleF();
|
var rectangle = rect.ToSystemRectangleF();
|
||||||
|
|
||||||
Assert.AreEqual(rect.x, rectangle.X);
|
Assert.That(rectangle.X, Is.EqualTo(rect.x));
|
||||||
Assert.AreEqual(rect.y, rectangle.Y);
|
Assert.That(rectangle.Y, Is.EqualTo(rect.y));
|
||||||
Assert.AreEqual(rect.width, rectangle.Width);
|
Assert.That(rectangle.Width, Is.EqualTo(rect.width));
|
||||||
Assert.AreEqual(rect.height, rectangle.Height);
|
Assert.That(rectangle.Height, Is.EqualTo(rect.height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var rect = new Rect(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle());
|
var rect = new Rect(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle());
|
||||||
var rectangle = rect.ToSystemRectangleF();
|
var rectangle = rect.ToSystemRectangleF();
|
||||||
|
|
||||||
Assert.AreEqual(rect.x, rectangle.X, 1e-6f);
|
Assert.That(rectangle.X, Is.EqualTo(rect.x).Within(1e-6f));
|
||||||
Assert.AreEqual(rect.y, rectangle.Y, 1e-6f);
|
Assert.That(rectangle.Y, Is.EqualTo(rect.y).Within(1e-6f));
|
||||||
Assert.AreEqual(rect.width, rectangle.Width, 1e-6f);
|
Assert.That(rectangle.Width, Is.EqualTo(rect.width).Within(1e-6f));
|
||||||
Assert.AreEqual(rect.height, rectangle.Height, 1e-6f);
|
Assert.That(rectangle.Height, Is.EqualTo(rect.height).Within(1e-6f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var rectangle = new RectangleF(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle());
|
var rectangle = new RectangleF(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle());
|
||||||
var rect = rectangle.ToUnityRect();
|
var rect = rectangle.ToUnityRect();
|
||||||
|
|
||||||
Assert.AreEqual(rectangle.X, rect.x, 1e-6f);
|
Assert.That(rect.x, Is.EqualTo(rectangle.X).Within(1e-6f));
|
||||||
Assert.AreEqual(rectangle.Y, rect.y, 1e-6f);
|
Assert.That(rect.y, Is.EqualTo(rectangle.Y).Within(1e-6f));
|
||||||
Assert.AreEqual(rectangle.Width, rect.width, 1e-6f);
|
Assert.That(rect.width, Is.EqualTo(rectangle.Width).Within(1e-6f));
|
||||||
Assert.AreEqual(rectangle.Height, rect.height, 1e-6f);
|
Assert.That(rect.height, Is.EqualTo(rectangle.Height).Within(1e-6f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next());
|
var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next());
|
||||||
var rect = rectangle.ToUnityRect();
|
var rect = rectangle.ToUnityRect();
|
||||||
|
|
||||||
Assert.AreEqual(rectangle.X, rect.x);
|
Assert.That(rect.x, Is.EqualTo(rectangle.X));
|
||||||
Assert.AreEqual(rectangle.Y, rect.y);
|
Assert.That(rect.y, Is.EqualTo(rectangle.Y));
|
||||||
Assert.AreEqual(rectangle.Width, rect.width);
|
Assert.That(rect.width, Is.EqualTo(rectangle.Width));
|
||||||
Assert.AreEqual(rectangle.Height, rect.height);
|
Assert.That(rect.height, Is.EqualTo(rectangle.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -27,10 +27,10 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next());
|
var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next());
|
||||||
var rect = rectangle.ToUnityRectInt();
|
var rect = rectangle.ToUnityRectInt();
|
||||||
|
|
||||||
Assert.AreEqual(rectangle.X, rect.x);
|
Assert.That(rect.x, Is.EqualTo(rectangle.X));
|
||||||
Assert.AreEqual(rectangle.Y, rect.y);
|
Assert.That(rect.y, Is.EqualTo(rectangle.Y));
|
||||||
Assert.AreEqual(rectangle.Width, rect.width);
|
Assert.That(rect.width, Is.EqualTo(rectangle.Width));
|
||||||
Assert.AreEqual(rectangle.Height, rect.height);
|
Assert.That(rect.height, Is.EqualTo(rectangle.Height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var size = new SizeF(random.NextSingle(), random.NextSingle());
|
var size = new SizeF(random.NextSingle(), random.NextSingle());
|
||||||
var vector = size.ToUnityVector2();
|
var vector = size.ToUnityVector2();
|
||||||
|
|
||||||
Assert.AreEqual(size.Width, vector.x, 1e-6f);
|
Assert.That(vector.x, Is.EqualTo(size.Width).Within(1e-6f));
|
||||||
Assert.AreEqual(size.Height, vector.y, 1e-6f);
|
Assert.That(vector.y, Is.EqualTo(size.Height).Within(1e-6f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var size = new Size(random.Next(), random.Next());
|
var size = new Size(random.Next(), random.Next());
|
||||||
var vector = size.ToUnityVector2();
|
var vector = size.ToUnityVector2();
|
||||||
|
|
||||||
Assert.AreEqual(size.Width, vector.x);
|
Assert.That(vector.x, Is.EqualTo(size.Width));
|
||||||
Assert.AreEqual(size.Height, vector.y);
|
Assert.That(vector.y, Is.EqualTo(size.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -25,8 +25,8 @@ namespace X10D.Unity.Tests.Drawing
|
|||||||
var size = new Size(random.Next(), random.Next());
|
var size = new Size(random.Next(), random.Next());
|
||||||
var vector = size.ToUnityVector2Int();
|
var vector = size.ToUnityVector2Int();
|
||||||
|
|
||||||
Assert.AreEqual(size.Width, vector.x);
|
Assert.That(vector.x, Is.EqualTo(size.Width));
|
||||||
Assert.AreEqual(size.Height, vector.y);
|
Assert.That(vector.y, Is.EqualTo(size.Height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ namespace X10D.Unity.Tests
|
|||||||
child.AddComponent<Rigidbody>();
|
child.AddComponent<Rigidbody>();
|
||||||
|
|
||||||
Rigidbody[] components = parent.GetComponentsInChildrenOnly<Rigidbody>();
|
Rigidbody[] components = parent.GetComponentsInChildrenOnly<Rigidbody>();
|
||||||
Assert.AreEqual(1, components.Length);
|
Assert.That(components.Length, Is.EqualTo(1));
|
||||||
Assert.AreEqual(components[0].gameObject, child);
|
Assert.That(child, Is.EqualTo(components[0].gameObject));
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
@ -34,29 +34,29 @@ namespace X10D.Unity.Tests
|
|||||||
Transform firstTransform = first.transform;
|
Transform firstTransform = first.transform;
|
||||||
Transform secondTransform = second.transform;
|
Transform secondTransform = second.transform;
|
||||||
|
|
||||||
Assert.AreEqual(Quaternion.identity, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity));
|
||||||
Assert.AreEqual(Quaternion.identity, secondTransform.rotation);
|
Assert.That(secondTransform.rotation, Is.EqualTo(Quaternion.identity));
|
||||||
|
|
||||||
firstTransform.LookAt(secondTransform);
|
firstTransform.LookAt(secondTransform);
|
||||||
Quaternion expected = firstTransform.rotation;
|
Quaternion expected = firstTransform.rotation;
|
||||||
|
|
||||||
firstTransform.rotation = Quaternion.identity;
|
firstTransform.rotation = Quaternion.identity;
|
||||||
Assert.AreEqual(Quaternion.identity, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity));
|
||||||
|
|
||||||
first.LookAt(second);
|
first.LookAt(second);
|
||||||
Assert.AreEqual(expected, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(expected));
|
||||||
|
|
||||||
firstTransform.rotation = Quaternion.identity;
|
firstTransform.rotation = Quaternion.identity;
|
||||||
Assert.AreEqual(Quaternion.identity, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity));
|
||||||
|
|
||||||
first.LookAt(second.transform);
|
first.LookAt(second.transform);
|
||||||
Assert.AreEqual(expected, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(expected));
|
||||||
|
|
||||||
firstTransform.rotation = Quaternion.identity;
|
firstTransform.rotation = Quaternion.identity;
|
||||||
Assert.AreEqual(Quaternion.identity, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity));
|
||||||
|
|
||||||
first.LookAt(Vector3.right);
|
first.LookAt(Vector3.right);
|
||||||
Assert.AreEqual(expected, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(expected));
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
@ -78,9 +78,9 @@ namespace X10D.Unity.Tests
|
|||||||
|
|
||||||
parent.SetLayerRecursively(layer);
|
parent.SetLayerRecursively(layer);
|
||||||
|
|
||||||
Assert.AreEqual(layer, parent.layer);
|
Assert.That(parent.layer, Is.EqualTo(layer));
|
||||||
Assert.AreEqual(layer, child.layer);
|
Assert.That(child.layer, Is.EqualTo(layer));
|
||||||
Assert.AreEqual(layer, grandChild.layer);
|
Assert.That(grandChild.layer, Is.EqualTo(layer));
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
@ -91,17 +91,17 @@ namespace X10D.Unity.Tests
|
|||||||
var first = new GameObject {transform = {position = Vector3.zero, rotation = Quaternion.identity}};
|
var first = new GameObject {transform = {position = Vector3.zero, rotation = Quaternion.identity}};
|
||||||
var second = new GameObject {transform = {position = Vector3.right, rotation = Quaternion.identity}};
|
var second = new GameObject {transform = {position = Vector3.right, rotation = Quaternion.identity}};
|
||||||
|
|
||||||
Assert.AreEqual(null, first.transform.parent);
|
Assert.That(first.transform.parent, Is.EqualTo(null));
|
||||||
Assert.AreEqual(null, second.transform.parent);
|
Assert.That(second.transform.parent, Is.EqualTo(null));
|
||||||
|
|
||||||
first.SetParent(second);
|
first.SetParent(second);
|
||||||
Assert.AreEqual(second.transform, first.transform.parent);
|
Assert.That(first.transform.parent, Is.EqualTo(second.transform));
|
||||||
|
|
||||||
first.transform.SetParent(null!);
|
first.transform.SetParent(null!);
|
||||||
Assert.AreEqual(null, first.transform.parent);
|
Assert.That(first.transform.parent, Is.EqualTo(null));
|
||||||
|
|
||||||
second.SetParent(first);
|
second.SetParent(first);
|
||||||
Assert.AreEqual(first.transform, second.transform.parent);
|
Assert.That(second.transform.parent, Is.EqualTo(first.transform));
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var quaternion = new Quaternion(x, y, z, w);
|
var quaternion = new Quaternion(x, y, z, w);
|
||||||
var systemQuaternion = quaternion.ToSystemQuaternion();
|
var systemQuaternion = quaternion.ToSystemQuaternion();
|
||||||
|
|
||||||
Assert.AreEqual(quaternion.x, systemQuaternion.X, 1e-6f);
|
Assert.That(systemQuaternion.X, Is.EqualTo(quaternion.x).Within(1e-6f));
|
||||||
Assert.AreEqual(quaternion.y, systemQuaternion.Y, 1e-6f);
|
Assert.That(systemQuaternion.Y, Is.EqualTo(quaternion.y).Within(1e-6f));
|
||||||
Assert.AreEqual(quaternion.z, systemQuaternion.Z, 1e-6f);
|
Assert.That(systemQuaternion.Z, Is.EqualTo(quaternion.z).Within(1e-6f));
|
||||||
Assert.AreEqual(quaternion.w, systemQuaternion.W, 1e-6f);
|
Assert.That(systemQuaternion.W, Is.EqualTo(quaternion.w).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -38,10 +38,10 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var quaternion = new System.Numerics.Quaternion(x, y, z, w);
|
var quaternion = new System.Numerics.Quaternion(x, y, z, w);
|
||||||
var unityQuaternion = quaternion.ToUnityQuaternion();
|
var unityQuaternion = quaternion.ToUnityQuaternion();
|
||||||
|
|
||||||
Assert.AreEqual(quaternion.X, unityQuaternion.x, 1e-6f);
|
Assert.That(unityQuaternion.x, Is.EqualTo(quaternion.X).Within(1e-6f));
|
||||||
Assert.AreEqual(quaternion.Y, unityQuaternion.y, 1e-6f);
|
Assert.That(unityQuaternion.y, Is.EqualTo(quaternion.Y).Within(1e-6f));
|
||||||
Assert.AreEqual(quaternion.Z, unityQuaternion.z, 1e-6f);
|
Assert.That(unityQuaternion.z, Is.EqualTo(quaternion.Z).Within(1e-6f));
|
||||||
Assert.AreEqual(quaternion.W, unityQuaternion.w, 1e-6f);
|
Assert.That(unityQuaternion.w, Is.EqualTo(quaternion.W).Within(1e-6f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
{
|
{
|
||||||
var random = new Random();
|
var random = new Random();
|
||||||
var vector = random.NextUnitVector2();
|
var vector = random.NextUnitVector2();
|
||||||
Assert.AreEqual(1, vector.magnitude, 1e-6);
|
Assert.That(vector.magnitude, Is.EqualTo(1).Within(1e-6));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -28,7 +28,7 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
{
|
{
|
||||||
var random = new Random();
|
var random = new Random();
|
||||||
var vector = random.NextUnitVector3();
|
var vector = random.NextUnitVector3();
|
||||||
Assert.AreEqual(1, vector.magnitude, 1e-6);
|
Assert.That(vector.magnitude, Is.EqualTo(1).Within(1e-6));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -13,8 +13,8 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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.That(x, Is.EqualTo(1));
|
||||||
Assert.AreEqual(2, y);
|
Assert.That(y, Is.EqualTo(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -27,8 +27,8 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new Vector2Int(x, y);
|
var vector = new Vector2Int(x, y);
|
||||||
var point = vector.ToSystemPoint();
|
var point = vector.ToSystemPoint();
|
||||||
|
|
||||||
Assert.AreEqual(vector.x, point.X);
|
Assert.That(point.X, Is.EqualTo(vector.x));
|
||||||
Assert.AreEqual(vector.y, point.Y);
|
Assert.That(point.Y, Is.EqualTo(vector.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -41,36 +41,36 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new Vector2Int(x, y);
|
var vector = new Vector2Int(x, y);
|
||||||
var point = vector.ToSystemSize();
|
var point = vector.ToSystemSize();
|
||||||
|
|
||||||
Assert.AreEqual(vector.x, point.Width);
|
Assert.That(point.Width, Is.EqualTo(vector.x));
|
||||||
Assert.AreEqual(vector.y, point.Height);
|
Assert.That(point.Height, Is.EqualTo(vector.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Vector2Int.up, Vector2Int.one.WithX(0));
|
Assert.That(Vector2Int.one.WithX(0), Is.EqualTo(Vector2Int.up));
|
||||||
Assert.AreEqual(Vector2Int.zero, Vector2Int.zero.WithX(0));
|
Assert.That(Vector2Int.zero.WithX(0), Is.EqualTo(Vector2Int.zero));
|
||||||
Assert.AreEqual(Vector2Int.zero, Vector2Int.right.WithX(0));
|
Assert.That(Vector2Int.right.WithX(0), Is.EqualTo(Vector2Int.zero));
|
||||||
Assert.AreEqual(Vector2Int.up, Vector2Int.up.WithX(0));
|
Assert.That(Vector2Int.up.WithX(0), Is.EqualTo(Vector2Int.up));
|
||||||
|
|
||||||
Assert.AreEqual(Vector2Int.one, Vector2Int.one.WithX(1));
|
Assert.That(Vector2Int.one.WithX(1), Is.EqualTo(Vector2Int.one));
|
||||||
Assert.AreEqual(Vector2Int.right, Vector2Int.zero.WithX(1));
|
Assert.That(Vector2Int.zero.WithX(1), Is.EqualTo(Vector2Int.right));
|
||||||
Assert.AreEqual(Vector2Int.right, Vector2Int.right.WithX(1));
|
Assert.That(Vector2Int.right.WithX(1), Is.EqualTo(Vector2Int.right));
|
||||||
Assert.AreEqual(Vector2Int.one, Vector2Int.up.WithX(1));
|
Assert.That(Vector2Int.up.WithX(1), Is.EqualTo(Vector2Int.one));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Vector2Int.right, Vector2Int.one.WithY(0));
|
Assert.That(Vector2Int.one.WithY(0), Is.EqualTo(Vector2Int.right));
|
||||||
Assert.AreEqual(Vector2Int.zero, Vector2Int.zero.WithY(0));
|
Assert.That(Vector2Int.zero.WithY(0), Is.EqualTo(Vector2Int.zero));
|
||||||
Assert.AreEqual(Vector2Int.right, Vector2Int.right.WithY(0));
|
Assert.That(Vector2Int.right.WithY(0), Is.EqualTo(Vector2Int.right));
|
||||||
Assert.AreEqual(Vector2Int.zero, Vector2Int.up.WithY(0));
|
Assert.That(Vector2Int.up.WithY(0), Is.EqualTo(Vector2Int.zero));
|
||||||
|
|
||||||
Assert.AreEqual(Vector2Int.one, Vector2Int.one.WithY(1));
|
Assert.That(Vector2Int.one.WithY(1), Is.EqualTo(Vector2Int.one));
|
||||||
Assert.AreEqual(Vector2Int.up, Vector2Int.zero.WithY(1));
|
Assert.That(Vector2Int.zero.WithY(1), Is.EqualTo(Vector2Int.up));
|
||||||
Assert.AreEqual(Vector2Int.one, Vector2Int.right.WithY(1));
|
Assert.That(Vector2Int.right.WithY(1), Is.EqualTo(Vector2Int.one));
|
||||||
Assert.AreEqual(Vector2Int.up, Vector2Int.up.WithY(1));
|
Assert.That(Vector2Int.up.WithY(1), Is.EqualTo(Vector2Int.up));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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.That(x, Is.EqualTo(1));
|
||||||
Assert.AreEqual(2, y);
|
Assert.That(y, Is.EqualTo(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -24,8 +24,8 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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.That(rounded.x, Is.EqualTo(2));
|
||||||
Assert.AreEqual(3, rounded.y);
|
Assert.That(rounded.y, Is.EqualTo(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -34,8 +34,8 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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.That(rounded.x, Is.EqualTo(0));
|
||||||
Assert.AreEqual(30, rounded.y);
|
Assert.That(rounded.y, Is.EqualTo(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -48,8 +48,8 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new Vector2(x, y);
|
var vector = new Vector2(x, y);
|
||||||
var point = vector.ToSystemPointF();
|
var point = vector.ToSystemPointF();
|
||||||
|
|
||||||
Assert.AreEqual(vector.x, point.X, 1e-6f);
|
Assert.That(point.X, Is.EqualTo(vector.x).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.y, point.Y, 1e-6f);
|
Assert.That(point.Y, Is.EqualTo(vector.y).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -62,8 +62,8 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new Vector2(x, y);
|
var vector = new Vector2(x, y);
|
||||||
var point = vector.ToSystemSizeF();
|
var point = vector.ToSystemSizeF();
|
||||||
|
|
||||||
Assert.AreEqual(vector.x, point.Width, 1e-6f);
|
Assert.That(point.Width, Is.EqualTo(vector.x).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.y, point.Height, 1e-6f);
|
Assert.That(point.Height, Is.EqualTo(vector.y).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -76,9 +76,9 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new Vector2(x, y);
|
var vector = new Vector2(x, y);
|
||||||
var systemVector = vector.ToSystemVector();
|
var systemVector = vector.ToSystemVector();
|
||||||
|
|
||||||
Assert.AreEqual(vector.magnitude, systemVector.Length(), 1e-6f);
|
Assert.That(systemVector.Length(), Is.EqualTo(vector.magnitude).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.x, systemVector.X, 1e-6f);
|
Assert.That(systemVector.X, Is.EqualTo(vector.x).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.y, systemVector.Y, 1e-6f);
|
Assert.That(systemVector.Y, Is.EqualTo(vector.y).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -91,37 +91,37 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new System.Numerics.Vector2(x, y);
|
var vector = new System.Numerics.Vector2(x, y);
|
||||||
var unityVector = vector.ToUnityVector();
|
var unityVector = vector.ToUnityVector();
|
||||||
|
|
||||||
Assert.AreEqual(vector.Length(), unityVector.magnitude, 1e-6f);
|
Assert.That(unityVector.magnitude, Is.EqualTo(vector.Length()).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.X, unityVector.x, 1e-6f);
|
Assert.That(unityVector.x, Is.EqualTo(vector.X).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.Y, unityVector.y, 1e-6f);
|
Assert.That(unityVector.y, Is.EqualTo(vector.Y).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Vector2.up, Vector2.one.WithX(0));
|
Assert.That(Vector2.one.WithX(0), Is.EqualTo(Vector2.up));
|
||||||
Assert.AreEqual(Vector2.zero, Vector2.zero.WithX(0));
|
Assert.That(Vector2.zero.WithX(0), Is.EqualTo(Vector2.zero));
|
||||||
Assert.AreEqual(Vector2.zero, Vector2.right.WithX(0));
|
Assert.That(Vector2.right.WithX(0), Is.EqualTo(Vector2.zero));
|
||||||
Assert.AreEqual(Vector2.up, Vector2.up.WithX(0));
|
Assert.That(Vector2.up.WithX(0), Is.EqualTo(Vector2.up));
|
||||||
|
|
||||||
Assert.AreEqual(Vector2.one, Vector2.one.WithX(1));
|
Assert.That(Vector2.one.WithX(1), Is.EqualTo(Vector2.one));
|
||||||
Assert.AreEqual(Vector2.right, Vector2.zero.WithX(1));
|
Assert.That(Vector2.zero.WithX(1), Is.EqualTo(Vector2.right));
|
||||||
Assert.AreEqual(Vector2.right, Vector2.right.WithX(1));
|
Assert.That(Vector2.right.WithX(1), Is.EqualTo(Vector2.right));
|
||||||
Assert.AreEqual(Vector2.one, Vector2.up.WithX(1));
|
Assert.That(Vector2.up.WithX(1), Is.EqualTo(Vector2.one));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(Vector2.right, Vector2.one.WithY(0));
|
Assert.That(Vector2.one.WithY(0), Is.EqualTo(Vector2.right));
|
||||||
Assert.AreEqual(Vector2.zero, Vector2.zero.WithY(0));
|
Assert.That(Vector2.zero.WithY(0), Is.EqualTo(Vector2.zero));
|
||||||
Assert.AreEqual(Vector2.right, Vector2.right.WithY(0));
|
Assert.That(Vector2.right.WithY(0), Is.EqualTo(Vector2.right));
|
||||||
Assert.AreEqual(Vector2.zero, Vector2.up.WithY(0));
|
Assert.That(Vector2.up.WithY(0), Is.EqualTo(Vector2.zero));
|
||||||
|
|
||||||
Assert.AreEqual(Vector2.one, Vector2.one.WithY(1));
|
Assert.That(Vector2.one.WithY(1), Is.EqualTo(Vector2.one));
|
||||||
Assert.AreEqual(Vector2.up, Vector2.zero.WithY(1));
|
Assert.That(Vector2.zero.WithY(1), Is.EqualTo(Vector2.up));
|
||||||
Assert.AreEqual(Vector2.one, Vector2.right.WithY(1));
|
Assert.That(Vector2.right.WithY(1), Is.EqualTo(Vector2.one));
|
||||||
Assert.AreEqual(Vector2.up, Vector2.up.WithY(1));
|
Assert.That(Vector2.up.WithY(1), Is.EqualTo(Vector2.up));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,57 +12,58 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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;
|
||||||
|
|
||||||
Assert.AreEqual(1, x);
|
Assert.That(x, Is.EqualTo(1));
|
||||||
Assert.AreEqual(2, y);
|
Assert.That(y, Is.EqualTo(2));
|
||||||
Assert.AreEqual(3, z);
|
Assert.That(z, Is.EqualTo(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.one.WithX(0));
|
Assert.That(Vector3Int.one.WithX(0), Is.EqualTo(new Vector3Int(0, 1, 1)));
|
||||||
Assert.AreEqual(Vector3Int.zero, Vector3Int.zero.WithX(0));
|
Assert.That(Vector3Int.zero.WithX(0), Is.EqualTo(Vector3Int.zero));
|
||||||
Assert.AreEqual(Vector3Int.zero, Vector3Int.right.WithX(0));
|
Assert.That(Vector3Int.right.WithX(0), Is.EqualTo(Vector3Int.zero));
|
||||||
Assert.AreEqual(Vector3Int.up, Vector3Int.up.WithX(0));
|
Assert.That(Vector3Int.up.WithX(0), Is.EqualTo(Vector3Int.up));
|
||||||
Assert.AreEqual(Vector3Int.forward, Vector3Int.forward.WithX(0));
|
Assert.That(Vector3Int.forward.WithX(0), Is.EqualTo(Vector3Int.forward));
|
||||||
|
|
||||||
Assert.AreEqual(Vector3Int.one, Vector3Int.one.WithX(1));
|
Assert.That(Vector3Int.one.WithX(1), Is.EqualTo(Vector3Int.one));
|
||||||
Assert.AreEqual(Vector3Int.right, Vector3Int.zero.WithX(1));
|
Assert.That(Vector3Int.zero.WithX(1), Is.EqualTo(Vector3Int.right));
|
||||||
Assert.AreEqual(Vector3Int.right, Vector3Int.right.WithX(1));
|
Assert.That(Vector3Int.right.WithX(1), Is.EqualTo(Vector3Int.right));
|
||||||
Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.up.WithX(1));
|
Assert.That(Vector3Int.up.WithX(1), Is.EqualTo(new Vector3Int(1, 1, 0)));
|
||||||
Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.forward.WithX(1));
|
Assert.That(Vector3Int.forward.WithX(1), Is.EqualTo(new Vector3Int(1, 0, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.one.WithY(0));
|
Assert.That(Vector3Int.one.WithY(0), Is.EqualTo(new Vector3Int(1, 0, 1)));
|
||||||
Assert.AreEqual(Vector3Int.zero, Vector3Int.zero.WithY(0));
|
Assert.That(Vector3Int.zero.WithY(0), Is.EqualTo(Vector3Int.zero));
|
||||||
Assert.AreEqual(Vector3Int.right, Vector3Int.right.WithY(0));
|
Assert.That(Vector3Int.right.WithY(0), Is.EqualTo(Vector3Int.right));
|
||||||
Assert.AreEqual(Vector3Int.zero, Vector3Int.up.WithY(0));
|
Assert.That(Vector3Int.up.WithY(0), Is.EqualTo(Vector3Int.zero));
|
||||||
Assert.AreEqual(Vector3Int.forward, Vector3Int.forward.WithY(0));
|
Assert.That(Vector3Int.forward.WithY(0), Is.EqualTo(Vector3Int.forward));
|
||||||
|
|
||||||
Assert.AreEqual(Vector3Int.one, Vector3Int.one.WithY(1));
|
Assert.That(Vector3Int.one.WithY(1), Is.EqualTo(Vector3Int.one));
|
||||||
Assert.AreEqual(Vector3Int.up, Vector3Int.zero.WithY(1));
|
Assert.That(Vector3Int.zero.WithY(1), Is.EqualTo(Vector3Int.up));
|
||||||
Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.right.WithY(1));
|
Assert.That(Vector3Int.right.WithY(1), Is.EqualTo(new Vector3Int(1, 1, 0)));
|
||||||
Assert.AreEqual(Vector3Int.up, Vector3Int.up.WithY(1));
|
Assert.That(Vector3Int.up.WithY(1), Is.EqualTo(Vector3Int.up));
|
||||||
Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.forward.WithY(1));
|
Assert.That(Vector3Int.forward.WithY(1), Is.EqualTo(new Vector3Int(0, 1, 1)));
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
|
public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector3Int(1, 1, 0), Vector3Int.one.WithZ(0));
|
Assert.That(Vector3Int.one.WithZ(0), Is.EqualTo(new Vector3Int(1, 1, 0)));
|
||||||
Assert.AreEqual(Vector3Int.zero, Vector3Int.zero.WithZ(0));
|
Assert.That(Vector3Int.zero.WithZ(0), Is.EqualTo(Vector3Int.zero));
|
||||||
Assert.AreEqual(Vector3Int.right, Vector3Int.right.WithZ(0));
|
Assert.That(Vector3Int.right.WithZ(0), Is.EqualTo(Vector3Int.right));
|
||||||
Assert.AreEqual(Vector3Int.up, Vector3Int.up.WithZ(0));
|
Assert.That(Vector3Int.up.WithZ(0), Is.EqualTo(Vector3Int.up));
|
||||||
Assert.AreEqual(Vector3Int.zero, Vector3Int.forward.WithZ(0));
|
Assert.That(Vector3Int.forward.WithZ(0), Is.EqualTo(Vector3Int.zero));
|
||||||
|
|
||||||
Assert.AreEqual(Vector3Int.one, Vector3Int.one.WithZ(1));
|
Assert.That(Vector3Int.one.WithZ(1), Is.EqualTo(Vector3Int.one));
|
||||||
Assert.AreEqual(Vector3Int.forward, Vector3Int.zero.WithZ(1));
|
Assert.That(Vector3Int.zero.WithZ(1), Is.EqualTo(Vector3Int.forward));
|
||||||
Assert.AreEqual(new Vector3Int(1, 0, 1), Vector3Int.right.WithZ(1));
|
Assert.That(Vector3Int.right.WithZ(1), Is.EqualTo(new Vector3Int(1, 0, 1)));
|
||||||
Assert.AreEqual(new Vector3Int(0, 1, 1), Vector3Int.up.WithZ(1));
|
Assert.That(Vector3Int.up.WithZ(1), Is.EqualTo(new Vector3Int(0, 1, 1)));
|
||||||
Assert.AreEqual(Vector3Int.forward, Vector3Int.forward.WithZ(1));
|
Assert.That(Vector3Int.forward.WithZ(1), Is.EqualTo(Vector3Int.forward));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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;
|
||||||
|
|
||||||
Assert.AreEqual(1, x);
|
Assert.That(x, Is.EqualTo(1));
|
||||||
Assert.AreEqual(2, y);
|
Assert.That(y, Is.EqualTo(2));
|
||||||
Assert.AreEqual(3, z);
|
Assert.That(z, Is.EqualTo(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -25,9 +25,9 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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();
|
||||||
|
|
||||||
Assert.AreEqual(2, rounded.x);
|
Assert.That(rounded.x, Is.EqualTo(2));
|
||||||
Assert.AreEqual(3, rounded.y);
|
Assert.That(rounded.y, Is.EqualTo(3));
|
||||||
Assert.AreEqual(-5, rounded.z);
|
Assert.That(rounded.z, Is.EqualTo(-5));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -36,9 +36,9 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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);
|
||||||
|
|
||||||
Assert.AreEqual(0, rounded.x);
|
Assert.That(rounded.x, Is.EqualTo(0));
|
||||||
Assert.AreEqual(30, rounded.y);
|
Assert.That(rounded.y, Is.EqualTo(30));
|
||||||
Assert.AreEqual(-10, rounded.z);
|
Assert.That(rounded.z, Is.EqualTo(-10));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -52,10 +52,10 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new Vector3(x, y, z);
|
var vector = new Vector3(x, y, z);
|
||||||
var systemVector = vector.ToSystemVector();
|
var systemVector = vector.ToSystemVector();
|
||||||
|
|
||||||
Assert.AreEqual(vector.magnitude, systemVector.Length(), 1e-6f);
|
Assert.That(systemVector.Length(), Is.EqualTo(vector.magnitude).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.x, systemVector.X, 1e-6f);
|
Assert.That(systemVector.X, Is.EqualTo(vector.x).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.y, systemVector.Y, 1e-6f);
|
Assert.That(systemVector.Y, Is.EqualTo(vector.y).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.z, systemVector.Z, 1e-6f);
|
Assert.That(systemVector.Z, Is.EqualTo(vector.z).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -69,58 +69,58 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new System.Numerics.Vector3(x, y, z);
|
var vector = new System.Numerics.Vector3(x, y, z);
|
||||||
var unityVector = vector.ToUnityVector();
|
var unityVector = vector.ToUnityVector();
|
||||||
|
|
||||||
Assert.AreEqual(vector.Length(), unityVector.magnitude, 1e-6f);
|
Assert.That(unityVector.magnitude, Is.EqualTo(vector.Length()).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.X, unityVector.x, 1e-6f);
|
Assert.That(unityVector.x, Is.EqualTo(vector.X).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.Y, unityVector.y, 1e-6f);
|
Assert.That(unityVector.y, Is.EqualTo(vector.Y).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.Z, unityVector.z, 1e-6f);
|
Assert.That(unityVector.z, Is.EqualTo(vector.Z).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector3(0, 1, 1), Vector3.one.WithX(0));
|
Assert.That(Vector3.one.WithX(0), Is.EqualTo(new Vector3(0, 1, 1)));
|
||||||
Assert.AreEqual(Vector3.zero, Vector3.zero.WithX(0));
|
Assert.That(Vector3.zero.WithX(0), Is.EqualTo(Vector3.zero));
|
||||||
Assert.AreEqual(Vector3.zero, Vector3.right.WithX(0));
|
Assert.That(Vector3.right.WithX(0), Is.EqualTo(Vector3.zero));
|
||||||
Assert.AreEqual(Vector3.up, Vector3.up.WithX(0));
|
Assert.That(Vector3.up.WithX(0), Is.EqualTo(Vector3.up));
|
||||||
Assert.AreEqual(Vector3.forward, Vector3.forward.WithX(0));
|
Assert.That(Vector3.forward.WithX(0), Is.EqualTo(Vector3.forward));
|
||||||
|
|
||||||
Assert.AreEqual(Vector3.one, Vector3.one.WithX(1));
|
Assert.That(Vector3.one.WithX(1), Is.EqualTo(Vector3.one));
|
||||||
Assert.AreEqual(Vector3.right, Vector3.zero.WithX(1));
|
Assert.That(Vector3.zero.WithX(1), Is.EqualTo(Vector3.right));
|
||||||
Assert.AreEqual(Vector3.right, Vector3.right.WithX(1));
|
Assert.That(Vector3.right.WithX(1), Is.EqualTo(Vector3.right));
|
||||||
Assert.AreEqual(new Vector3(1, 1, 0), Vector3.up.WithX(1));
|
Assert.That(Vector3.up.WithX(1), Is.EqualTo(new Vector3(1, 1, 0)));
|
||||||
Assert.AreEqual(new Vector3(1, 0, 1), Vector3.forward.WithX(1));
|
Assert.That(Vector3.forward.WithX(1), Is.EqualTo(new Vector3(1, 0, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector3(1, 0, 1), Vector3.one.WithY(0));
|
Assert.That(Vector3.one.WithY(0), Is.EqualTo(new Vector3(1, 0, 1)));
|
||||||
Assert.AreEqual(Vector3.zero, Vector3.zero.WithY(0));
|
Assert.That(Vector3.zero.WithY(0), Is.EqualTo(Vector3.zero));
|
||||||
Assert.AreEqual(Vector3.right, Vector3.right.WithY(0));
|
Assert.That(Vector3.right.WithY(0), Is.EqualTo(Vector3.right));
|
||||||
Assert.AreEqual(Vector3.zero, Vector3.up.WithY(0));
|
Assert.That(Vector3.up.WithY(0), Is.EqualTo(Vector3.zero));
|
||||||
Assert.AreEqual(Vector3.forward, Vector3.forward.WithY(0));
|
Assert.That(Vector3.forward.WithY(0), Is.EqualTo(Vector3.forward));
|
||||||
|
|
||||||
Assert.AreEqual(Vector3.one, Vector3.one.WithY(1));
|
Assert.That(Vector3.one.WithY(1), Is.EqualTo(Vector3.one));
|
||||||
Assert.AreEqual(Vector3.up, Vector3.zero.WithY(1));
|
Assert.That(Vector3.zero.WithY(1), Is.EqualTo(Vector3.up));
|
||||||
Assert.AreEqual(new Vector3(1, 1, 0), Vector3.right.WithY(1));
|
Assert.That(Vector3.right.WithY(1), Is.EqualTo(new Vector3(1, 1, 0)));
|
||||||
Assert.AreEqual(Vector3.up, Vector3.up.WithY(1));
|
Assert.That(Vector3.up.WithY(1), Is.EqualTo(Vector3.up));
|
||||||
Assert.AreEqual(new Vector3(0, 1, 1), Vector3.forward.WithY(1));
|
Assert.That(Vector3.forward.WithY(1), Is.EqualTo(new Vector3(0, 1, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
|
public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector3(1, 1, 0), Vector3.one.WithZ(0));
|
Assert.That(Vector3.one.WithZ(0), Is.EqualTo(new Vector3(1, 1, 0)));
|
||||||
Assert.AreEqual(Vector3.zero, Vector3.zero.WithZ(0));
|
Assert.That(Vector3.zero.WithZ(0), Is.EqualTo(Vector3.zero));
|
||||||
Assert.AreEqual(Vector3.right, Vector3.right.WithZ(0));
|
Assert.That(Vector3.right.WithZ(0), Is.EqualTo(Vector3.right));
|
||||||
Assert.AreEqual(Vector3.up, Vector3.up.WithZ(0));
|
Assert.That(Vector3.up.WithZ(0), Is.EqualTo(Vector3.up));
|
||||||
Assert.AreEqual(Vector3.zero, Vector3.forward.WithZ(0));
|
Assert.That(Vector3.forward.WithZ(0), Is.EqualTo(Vector3.zero));
|
||||||
|
|
||||||
Assert.AreEqual(Vector3.one, Vector3.one.WithZ(1));
|
Assert.That(Vector3.one.WithZ(1), Is.EqualTo(Vector3.one));
|
||||||
Assert.AreEqual(Vector3.forward, Vector3.zero.WithZ(1));
|
Assert.That(Vector3.zero.WithZ(1), Is.EqualTo(Vector3.forward));
|
||||||
Assert.AreEqual(new Vector3(1, 0, 1), Vector3.right.WithZ(1));
|
Assert.That(Vector3.right.WithZ(1), Is.EqualTo(new Vector3(1, 0, 1)));
|
||||||
Assert.AreEqual(new Vector3(0, 1, 1), Vector3.up.WithZ(1));
|
Assert.That(Vector3.up.WithZ(1), Is.EqualTo(new Vector3(0, 1, 1)));
|
||||||
Assert.AreEqual(Vector3.forward, Vector3.forward.WithZ(1));
|
Assert.That(Vector3.forward.WithZ(1), Is.EqualTo(Vector3.forward));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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;
|
||||||
|
|
||||||
Assert.AreEqual(1, x);
|
Assert.That(x, Is.EqualTo(1));
|
||||||
Assert.AreEqual(2, y);
|
Assert.That(y, Is.EqualTo(2));
|
||||||
Assert.AreEqual(3, z);
|
Assert.That(z, Is.EqualTo(3));
|
||||||
Assert.AreEqual(4, w);
|
Assert.That(w, Is.EqualTo(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -26,10 +26,10 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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();
|
||||||
|
|
||||||
Assert.AreEqual(2, rounded.x);
|
Assert.That(rounded.x, Is.EqualTo(2));
|
||||||
Assert.AreEqual(3, rounded.y);
|
Assert.That(rounded.y, Is.EqualTo(3));
|
||||||
Assert.AreEqual(-5, rounded.z);
|
Assert.That(rounded.z, Is.EqualTo(-5));
|
||||||
Assert.AreEqual(0, rounded.w);
|
Assert.That(rounded.w, Is.EqualTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -38,10 +38,10 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
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);
|
||||||
|
|
||||||
Assert.AreEqual(0, rounded.x);
|
Assert.That(rounded.x, Is.EqualTo(0));
|
||||||
Assert.AreEqual(30, rounded.y);
|
Assert.That(rounded.y, Is.EqualTo(30));
|
||||||
Assert.AreEqual(-10, rounded.z);
|
Assert.That(rounded.z, Is.EqualTo(-10));
|
||||||
Assert.AreEqual(100, rounded.w);
|
Assert.That(rounded.w, Is.EqualTo(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -56,11 +56,11 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new Vector4(x, y, z, w);
|
var vector = new Vector4(x, y, z, w);
|
||||||
var systemVector = vector.ToSystemVector();
|
var systemVector = vector.ToSystemVector();
|
||||||
|
|
||||||
Assert.AreEqual(vector.magnitude, systemVector.Length(), 1e-6f);
|
Assert.That(systemVector.Length(), Is.EqualTo(vector.magnitude).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.x, systemVector.X, 1e-6f);
|
Assert.That(systemVector.X, Is.EqualTo(vector.x).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.y, systemVector.Y, 1e-6f);
|
Assert.That(systemVector.Y, Is.EqualTo(vector.y).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.z, systemVector.Z, 1e-6f);
|
Assert.That(systemVector.Z, Is.EqualTo(vector.z).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.w, systemVector.W, 1e-6f);
|
Assert.That(systemVector.W, Is.EqualTo(vector.w).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -75,83 +75,83 @@ namespace X10D.Unity.Tests.Numerics
|
|||||||
var vector = new System.Numerics.Vector4(x, y, z, w);
|
var vector = new System.Numerics.Vector4(x, y, z, w);
|
||||||
var unityVector = vector.ToUnityVector();
|
var unityVector = vector.ToUnityVector();
|
||||||
|
|
||||||
Assert.AreEqual(vector.Length(), unityVector.magnitude, 1e-6f);
|
Assert.That(unityVector.magnitude, Is.EqualTo(vector.Length()).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.X, unityVector.x, 1e-6f);
|
Assert.That(unityVector.x, Is.EqualTo(vector.X).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.Y, unityVector.y, 1e-6f);
|
Assert.That(unityVector.y, Is.EqualTo(vector.Y).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.Z, unityVector.z, 1e-6f);
|
Assert.That(unityVector.z, Is.EqualTo(vector.Z).Within(1e-6f));
|
||||||
Assert.AreEqual(vector.W, unityVector.w, 1e-6f);
|
Assert.That(unityVector.w, Is.EqualTo(vector.W).Within(1e-6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithW_ShouldReturnVectorWithNewW_GivenVector()
|
public void WithW_ShouldReturnVectorWithNewW_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector4(1, 1, 1, 0), Vector4.one.WithW(0));
|
Assert.That(Vector4.one.WithW(0), Is.EqualTo(new Vector4(1, 1, 1, 0)));
|
||||||
Assert.AreEqual(Vector4.zero, Vector4.zero.WithW(0));
|
Assert.That(Vector4.zero.WithW(0), Is.EqualTo(Vector4.zero));
|
||||||
Assert.AreEqual(Vector4.zero, new Vector4(0, 0, 0, 1).WithW(0));
|
Assert.That(new Vector4(0, 0, 0, 1).WithW(0), Is.EqualTo(Vector4.zero));
|
||||||
Assert.AreEqual(new Vector4(1, 0, 0, 0), new Vector4(1, 0, 0, 0).WithW(0));
|
Assert.That(new Vector4(1, 0, 0, 0).WithW(0), Is.EqualTo(new Vector4(1, 0, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 1, 0, 0), new Vector4(0, 1, 0, 0).WithW(0));
|
Assert.That(new Vector4(0, 1, 0, 0).WithW(0), Is.EqualTo(new Vector4(0, 1, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 1, 0), new Vector4(0, 0, 1, 0).WithW(0));
|
Assert.That(new Vector4(0, 0, 1, 0).WithW(0), Is.EqualTo(new Vector4(0, 0, 1, 0)));
|
||||||
|
|
||||||
Assert.AreEqual(Vector4.one, Vector4.one.WithW(1));
|
Assert.That(Vector4.one.WithW(1), Is.EqualTo(Vector4.one));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 0, 1), Vector4.zero.WithW(1));
|
Assert.That(Vector4.zero.WithW(1), Is.EqualTo(new Vector4(0, 0, 0, 1)));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 0, 1), new Vector4(0, 0, 0, 1).WithW(1));
|
Assert.That(new Vector4(0, 0, 0, 1).WithW(1), Is.EqualTo(new Vector4(0, 0, 0, 1)));
|
||||||
Assert.AreEqual(new Vector4(1, 0, 0, 1), new Vector4(1, 0, 0, 0).WithW(1));
|
Assert.That(new Vector4(1, 0, 0, 0).WithW(1), Is.EqualTo(new Vector4(1, 0, 0, 1)));
|
||||||
Assert.AreEqual(new Vector4(0, 1, 0, 1), new Vector4(0, 1, 0, 0).WithW(1));
|
Assert.That(new Vector4(0, 1, 0, 0).WithW(1), Is.EqualTo(new Vector4(0, 1, 0, 1)));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 1, 1), new Vector4(0, 0, 1, 0).WithW(1));
|
Assert.That(new Vector4(0, 0, 1, 0).WithW(1), Is.EqualTo(new Vector4(0, 0, 1, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector4(0, 1, 1, 1), Vector4.one.WithX(0));
|
Assert.That(Vector4.one.WithX(0), Is.EqualTo(new Vector4(0, 1, 1, 1)));
|
||||||
Assert.AreEqual(Vector4.zero, Vector4.zero.WithX(0));
|
Assert.That(Vector4.zero.WithX(0), Is.EqualTo(Vector4.zero));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 0, 1), new Vector4(0, 0, 0, 1).WithX(0));
|
Assert.That(new Vector4(0, 0, 0, 1).WithX(0), Is.EqualTo(new Vector4(0, 0, 0, 1)));
|
||||||
Assert.AreEqual(Vector4.zero, new Vector4(1, 0, 0, 0).WithX(0));
|
Assert.That(new Vector4(1, 0, 0, 0).WithX(0), Is.EqualTo(Vector4.zero));
|
||||||
Assert.AreEqual(new Vector4(0, 1, 0, 0), new Vector4(0, 1, 0, 0).WithX(0));
|
Assert.That(new Vector4(0, 1, 0, 0).WithX(0), Is.EqualTo(new Vector4(0, 1, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 1, 0), new Vector4(0, 0, 1, 0).WithX(0));
|
Assert.That(new Vector4(0, 0, 1, 0).WithX(0), Is.EqualTo(new Vector4(0, 0, 1, 0)));
|
||||||
|
|
||||||
Assert.AreEqual(Vector4.one, Vector4.one.WithX(1));
|
Assert.That(Vector4.one.WithX(1), Is.EqualTo(Vector4.one));
|
||||||
Assert.AreEqual(new Vector4(1, 0, 0, 0), Vector4.zero.WithX(1));
|
Assert.That(Vector4.zero.WithX(1), Is.EqualTo(new Vector4(1, 0, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(1, 0, 0, 1), new Vector4(0, 0, 0, 1).WithX(1));
|
Assert.That(new Vector4(0, 0, 0, 1).WithX(1), Is.EqualTo(new Vector4(1, 0, 0, 1)));
|
||||||
Assert.AreEqual(new Vector4(1, 0, 0, 0), new Vector4(1, 0, 0, 0).WithX(1));
|
Assert.That(new Vector4(1, 0, 0, 0).WithX(1), Is.EqualTo(new Vector4(1, 0, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(1, 1, 0, 0), new Vector4(0, 1, 0, 0).WithX(1));
|
Assert.That(new Vector4(0, 1, 0, 0).WithX(1), Is.EqualTo(new Vector4(1, 1, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(1, 0, 1, 0), new Vector4(0, 0, 1, 0).WithX(1));
|
Assert.That(new Vector4(0, 0, 1, 0).WithX(1), Is.EqualTo(new Vector4(1, 0, 1, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
public void WithY_ShouldReturnVectorWithNewY_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector4(1, 0, 1, 1), Vector4.one.WithY(0));
|
Assert.That(Vector4.one.WithY(0), Is.EqualTo(new Vector4(1, 0, 1, 1)));
|
||||||
Assert.AreEqual(Vector4.zero, Vector4.zero.WithY(0));
|
Assert.That(Vector4.zero.WithY(0), Is.EqualTo(Vector4.zero));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 0, 1), new Vector4(0, 0, 0, 1).WithY(0));
|
Assert.That(new Vector4(0, 0, 0, 1).WithY(0), Is.EqualTo(new Vector4(0, 0, 0, 1)));
|
||||||
Assert.AreEqual(new Vector4(1, 0, 0, 0), new Vector4(1, 0, 0, 0).WithY(0));
|
Assert.That(new Vector4(1, 0, 0, 0).WithY(0), Is.EqualTo(new Vector4(1, 0, 0, 0)));
|
||||||
Assert.AreEqual(Vector4.zero, new Vector4(0, 1, 0, 0).WithY(0));
|
Assert.That(new Vector4(0, 1, 0, 0).WithY(0), Is.EqualTo(Vector4.zero));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 1, 0), new Vector4(0, 0, 1, 0).WithY(0));
|
Assert.That(new Vector4(0, 0, 1, 0).WithY(0), Is.EqualTo(new Vector4(0, 0, 1, 0)));
|
||||||
|
|
||||||
Assert.AreEqual(Vector4.one, Vector4.one.WithY(1));
|
Assert.That(Vector4.one.WithY(1), Is.EqualTo(Vector4.one));
|
||||||
Assert.AreEqual(new Vector4(0, 1, 0, 0), Vector4.zero.WithY(1));
|
Assert.That(Vector4.zero.WithY(1), Is.EqualTo(new Vector4(0, 1, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 1, 0, 1), new Vector4(0, 0, 0, 1).WithY(1));
|
Assert.That(new Vector4(0, 0, 0, 1).WithY(1), Is.EqualTo(new Vector4(0, 1, 0, 1)));
|
||||||
Assert.AreEqual(new Vector4(1, 1, 0, 0), new Vector4(1, 0, 0, 0).WithY(1));
|
Assert.That(new Vector4(1, 0, 0, 0).WithY(1), Is.EqualTo(new Vector4(1, 1, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 1, 0, 0), new Vector4(0, 1, 0, 0).WithY(1));
|
Assert.That(new Vector4(0, 1, 0, 0).WithY(1), Is.EqualTo(new Vector4(0, 1, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 1, 1, 0), new Vector4(0, 0, 1, 0).WithY(1));
|
Assert.That(new Vector4(0, 0, 1, 0).WithY(1), Is.EqualTo(new Vector4(0, 1, 1, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
|
public void WithZ_ShouldReturnVectorWithNewZ_GivenVector()
|
||||||
{
|
{
|
||||||
Assert.AreEqual(new Vector4(1, 1, 0, 1), Vector4.one.WithZ(0));
|
Assert.That(Vector4.one.WithZ(0), Is.EqualTo(new Vector4(1, 1, 0, 1)));
|
||||||
Assert.AreEqual(Vector4.zero, Vector4.zero.WithZ(0));
|
Assert.That(Vector4.zero.WithZ(0), Is.EqualTo(Vector4.zero));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 0, 1), new Vector4(0, 0, 0, 1).WithZ(0));
|
Assert.That(new Vector4(0, 0, 0, 1).WithZ(0), Is.EqualTo(new Vector4(0, 0, 0, 1)));
|
||||||
Assert.AreEqual(new Vector4(1, 0, 0, 0), new Vector4(1, 0, 0, 0).WithZ(0));
|
Assert.That(new Vector4(1, 0, 0, 0).WithZ(0), Is.EqualTo(new Vector4(1, 0, 0, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 1, 0, 0), new Vector4(0, 1, 0, 0).WithZ(0));
|
Assert.That(new Vector4(0, 1, 0, 0).WithZ(0), Is.EqualTo(new Vector4(0, 1, 0, 0)));
|
||||||
Assert.AreEqual(Vector4.zero, new Vector4(0, 0, 1, 0).WithZ(0));
|
Assert.That(new Vector4(0, 0, 1, 0).WithZ(0), Is.EqualTo(Vector4.zero));
|
||||||
|
|
||||||
Assert.AreEqual(Vector4.one, Vector4.one.WithZ(1));
|
Assert.That(Vector4.one.WithZ(1), Is.EqualTo(Vector4.one));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 1, 0), Vector4.zero.WithZ(1));
|
Assert.That(Vector4.zero.WithZ(1), Is.EqualTo(new Vector4(0, 0, 1, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 1, 1), new Vector4(0, 0, 0, 1).WithZ(1));
|
Assert.That(new Vector4(0, 0, 0, 1).WithZ(1), Is.EqualTo(new Vector4(0, 0, 1, 1)));
|
||||||
Assert.AreEqual(new Vector4(1, 0, 1, 0), new Vector4(1, 0, 0, 0).WithZ(1));
|
Assert.That(new Vector4(1, 0, 0, 0).WithZ(1), Is.EqualTo(new Vector4(1, 0, 1, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 1, 1, 0), new Vector4(0, 1, 0, 0).WithZ(1));
|
Assert.That(new Vector4(0, 1, 0, 0).WithZ(1), Is.EqualTo(new Vector4(0, 1, 1, 0)));
|
||||||
Assert.AreEqual(new Vector4(0, 0, 1, 0), new Vector4(0, 0, 1, 0).WithZ(1));
|
Assert.That(new Vector4(0, 0, 1, 0).WithZ(1), Is.EqualTo(new Vector4(0, 0, 1, 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,23 +11,23 @@ namespace X10D.Unity.Tests
|
|||||||
public void Singleton_ShouldReturnNewInstance_WhenNoInstanceExists()
|
public void Singleton_ShouldReturnNewInstance_WhenNoInstanceExists()
|
||||||
{
|
{
|
||||||
TestBehaviour instance = Singleton<TestBehaviour>.Instance;
|
TestBehaviour instance = Singleton<TestBehaviour>.Instance;
|
||||||
Assert.IsNotNull(instance);
|
Assert.That(instance, Is.Not.Null);
|
||||||
Assert.IsTrue(instance.Flag);
|
Assert.That(instance.Flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Singleton_ShouldReturnSameInstance_WhenAccessedTwice()
|
public void Singleton_ShouldReturnSameInstance_WhenAccessedTwice()
|
||||||
{
|
{
|
||||||
TestBehaviour instance = Singleton<TestBehaviour>.Instance;
|
TestBehaviour instance = Singleton<TestBehaviour>.Instance;
|
||||||
Assert.IsNotNull(instance);
|
Assert.That(instance, Is.Not.Null);
|
||||||
Assert.AreEqual(instance, Singleton<TestBehaviour>.Instance);
|
Assert.That(Singleton<TestBehaviour>.Instance, Is.EqualTo(instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
[UnityTest]
|
[UnityTest]
|
||||||
public IEnumerator Singleton_ShouldReturnNewInstance_WhenDestroyed()
|
public IEnumerator Singleton_ShouldReturnNewInstance_WhenDestroyed()
|
||||||
{
|
{
|
||||||
TestBehaviour instance = Singleton<TestBehaviour>.Instance;
|
TestBehaviour instance = Singleton<TestBehaviour>.Instance;
|
||||||
Assert.IsNotNull(instance);
|
Assert.That(instance, Is.Not.Null);
|
||||||
Object.Destroy(instance);
|
Object.Destroy(instance);
|
||||||
|
|
||||||
yield return null;
|
yield return null;
|
||||||
@ -36,7 +36,7 @@ namespace X10D.Unity.Tests
|
|||||||
|
|
||||||
// ReSharper disable once HeuristicUnreachableCode
|
// ReSharper disable once HeuristicUnreachableCode
|
||||||
instance = Singleton<TestBehaviour>.Instance;
|
instance = Singleton<TestBehaviour>.Instance;
|
||||||
Assert.IsNotNull(instance);
|
Assert.That(instance, Is.Not.Null);
|
||||||
Assert.IsTrue(instance.Flag);
|
Assert.IsTrue(instance.Flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,20 +17,20 @@ namespace X10D.Unity.Tests
|
|||||||
Transform firstTransform = first.transform;
|
Transform firstTransform = first.transform;
|
||||||
Transform secondTransform = second.transform;
|
Transform secondTransform = second.transform;
|
||||||
|
|
||||||
Assert.AreEqual(Quaternion.identity, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity));
|
||||||
Assert.AreEqual(Quaternion.identity, secondTransform.rotation);
|
Assert.That(secondTransform.rotation, Is.EqualTo(Quaternion.identity));
|
||||||
|
|
||||||
firstTransform.LookAt(secondTransform);
|
firstTransform.LookAt(secondTransform);
|
||||||
Quaternion expected = firstTransform.rotation;
|
Quaternion expected = firstTransform.rotation;
|
||||||
|
|
||||||
firstTransform.rotation = Quaternion.identity;
|
firstTransform.rotation = Quaternion.identity;
|
||||||
Assert.AreEqual(Quaternion.identity, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity));
|
||||||
|
|
||||||
firstTransform.LookAt(second);
|
firstTransform.LookAt(second);
|
||||||
Assert.AreEqual(expected, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(expected));
|
||||||
|
|
||||||
firstTransform.rotation = Quaternion.identity;
|
firstTransform.rotation = Quaternion.identity;
|
||||||
Assert.AreEqual(Quaternion.identity, firstTransform.rotation);
|
Assert.That(firstTransform.rotation, Is.EqualTo(Quaternion.identity));
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
@ -41,17 +41,17 @@ namespace X10D.Unity.Tests
|
|||||||
var first = new GameObject {transform = {position = Vector3.zero, rotation = Quaternion.identity}};
|
var first = new GameObject {transform = {position = Vector3.zero, rotation = Quaternion.identity}};
|
||||||
var second = new GameObject {transform = {position = Vector3.right, rotation = Quaternion.identity}};
|
var second = new GameObject {transform = {position = Vector3.right, rotation = Quaternion.identity}};
|
||||||
|
|
||||||
Assert.AreEqual(null, first.transform.parent);
|
Assert.That(first.transform.parent, Is.EqualTo(null));
|
||||||
Assert.AreEqual(null, second.transform.parent);
|
Assert.That(second.transform.parent, Is.EqualTo(null));
|
||||||
|
|
||||||
first.transform.SetParent(second);
|
first.transform.SetParent(second);
|
||||||
Assert.AreEqual(second.transform, first.transform.parent);
|
Assert.That(first.transform.parent, Is.EqualTo(second.transform));
|
||||||
|
|
||||||
first.transform.SetParent(null!);
|
first.transform.SetParent(null!);
|
||||||
Assert.AreEqual(null, first.transform.parent);
|
Assert.That(first.transform.parent, Is.EqualTo(null));
|
||||||
|
|
||||||
second.transform.SetParent(first);
|
second.transform.SetParent(first);
|
||||||
Assert.AreEqual(first.transform, second.transform.parent);
|
Assert.That(second.transform.parent, Is.EqualTo(first.transform));
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace X10D.Unity.Tests
|
|||||||
{
|
{
|
||||||
int frameCount = UTime.frameCount;
|
int frameCount = UTime.frameCount;
|
||||||
yield return new WaitForFrames(10);
|
yield return new WaitForFrames(10);
|
||||||
Assert.AreEqual(frameCount + 10, UTime.frameCount, $"{frameCount + 10} == {UTime.frameCount}");
|
Assert.That(UTime.frameCount, Is.EqualTo(frameCount + 10), $"{frameCount + 10} == {UTime.frameCount}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[UnityTest]
|
[UnityTest]
|
||||||
@ -22,7 +22,7 @@ namespace X10D.Unity.Tests
|
|||||||
{
|
{
|
||||||
float time = UTime.time;
|
float time = UTime.time;
|
||||||
yield return new WaitForSecondsNoAlloc(2);
|
yield return new WaitForSecondsNoAlloc(2);
|
||||||
Assert.AreEqual(time + 2, UTime.time, 1e-2, $"{time + 2} == {UTime.time}");
|
Assert.That(UTime.time, Is.EqualTo(time + 2).Within(1e-2), $"{time + 2} == {UTime.time}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[UnityTest]
|
[UnityTest]
|
||||||
@ -30,34 +30,23 @@ namespace X10D.Unity.Tests
|
|||||||
{
|
{
|
||||||
float time = UTime.time;
|
float time = UTime.time;
|
||||||
yield return new WaitForSecondsRealtimeNoAlloc(2);
|
yield return new WaitForSecondsRealtimeNoAlloc(2);
|
||||||
Assert.AreEqual(time + 2, UTime.time, 1e-2, $"{time + 2} == {UTime.time}");
|
Assert.That(UTime.time, Is.EqualTo(time + 2).Within(1e-2), $"{time + 2} == {UTime.time}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[UnityTest]
|
[UnityTest]
|
||||||
public IEnumerator WaitForTimeSpan_ShouldYieldForCorrectTime()
|
public IEnumerator WaitForTimeSpan_ShouldYieldForCorrectTime()
|
||||||
{
|
{
|
||||||
float time = UTime.time;
|
float time = UTime.time;
|
||||||
yield return new WaitForTimeSpan(TimeSpan.FromSeconds(2));
|
yield return new WaitForTimeSpan(TimeSpan.FromSeconds(2.0));
|
||||||
if (System.Math.Abs(UTime.time - (time + 2)) < 1e-1)
|
Assert.That(UTime.time, Is.GreaterThanOrEqualTo(time + 2.0f).Or.GreaterThanOrEqualTo(time + 1.5f));
|
||||||
{
|
|
||||||
Assert.Pass($"{time + 2} == {UTime.time}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// when this method runs on CI, it fails because the job waits for 159
|
|
||||||
// seconds rather than 2. I have no idea why. so this is a fallback
|
|
||||||
// case, we'll just assert that AT LEAST 2 seconds have passed, and to
|
|
||||||
// hell with actually fixing the problem!
|
|
||||||
Assert.IsTrue(UTime.time > time + 1.98, $"{UTime.time} > {time + 2}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[UnityTest]
|
[UnityTest]
|
||||||
public IEnumerator WaitForTimeSpanRealtime_ShouldYieldForCorrectTime()
|
public IEnumerator WaitForTimeSpanRealtime_ShouldYieldForCorrectTime()
|
||||||
{
|
{
|
||||||
float time = UTime.time;
|
float time = UTime.time;
|
||||||
yield return new WaitForTimeSpanRealtime(TimeSpan.FromSeconds(2));
|
yield return new WaitForTimeSpanRealtime(TimeSpan.FromSeconds(2.0));
|
||||||
Assert.AreEqual(time + 2, UTime.time, 1e-2, $"{time + 2} == {UTime.time}");
|
Assert.That(UTime.time, Is.EqualTo(time + 2).Within(1e-2), $"{time + 2} == {UTime.time}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user