- Started Windows, Metro and Linux Platform-Plugins - Moved the RecordingSample to the Samples folder - Started two samples for using the graphics device in a WinForms and Wpf Editor - Refactorings in the AddIn-System - Moved the Window initialization-code to the Platform modules - Changed the License text in all code files which is now way smaller - Started ProjectConverter tool which converts all the projects and solution to the target configuration - Changed the SupportedPlatform names in the Resource files - Changed the WIN8 define to WINDOWSMETRO which is actually meant - Removed NLog and started our own Logger class - Many more stuff...
277 lines
8.9 KiB
C#
277 lines
8.9 KiB
C#
#region Using Statements
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using NUnit.Framework;
|
|
|
|
#endregion // Using Statements
|
|
|
|
// This file is part of the ANX.Framework created by the
|
|
// "ANX.Framework developer group" and released under the Ms-PL license.
|
|
// For details see: http://anxframework.codeplex.com/license
|
|
|
|
using XNARect = Microsoft.Xna.Framework.Rectangle;
|
|
using ANXRect = ANX.Framework.Rectangle;
|
|
|
|
namespace ANX.Framework.TestCenter.Strukturen
|
|
{
|
|
|
|
[TestFixture]
|
|
class RectangleTest
|
|
{
|
|
static object[] ninefloats =
|
|
{
|
|
|
|
|
|
new object[] {0,0,0,0},
|
|
new object[] {1,2,3,4},
|
|
new object[] {-1,-2,3,4},
|
|
new object[] {1,-2,0,0}
|
|
|
|
|
|
};
|
|
|
|
static object[] ninefloats6 =
|
|
{
|
|
|
|
|
|
new object[] {0,0,0,0,0,0,0,0},
|
|
new object[] {1,2,3,4,0,0,2,5},
|
|
new object[] {-1,-2,3,4,1,10,1,5},
|
|
new object[] {1,-2,0,0,3,1,2,1}
|
|
|
|
|
|
};
|
|
#region properties
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void Bottom(int x1, int y1, int w1, int h1)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
|
|
int xnaR = xna.Bottom;
|
|
int anxR = anx.Bottom;
|
|
Assert.AreEqual(xnaR, anxR);
|
|
}
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void Center(int x1, int y1, int w1, int h1)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
|
|
int xnaRX = xna.Center.X;
|
|
int anxRX = anx.Center.X;
|
|
|
|
int xnaRY = xna.Center.Y;
|
|
int anxRY = anx.Center.Y;
|
|
Assert.AreEqual(xnaRX, anxRX);
|
|
Assert.AreEqual(xnaRY, anxRY);
|
|
}
|
|
[Test]
|
|
public void Empty()
|
|
{
|
|
AssertHelper.ConvertEquals(XNARect.Empty, ANXRect.Empty, "Empty");
|
|
|
|
|
|
}
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void ToString(int x1, int y1, int w1, int h1)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
String xnaR = xna.ToString();
|
|
String anxR = anx.ToString();
|
|
Assert.AreEqual(xnaR, anxR);
|
|
}
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void IsEmpty(int x1, int y1, int w1, int h1)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
Assert.AreEqual(xna.IsEmpty, anx.IsEmpty);
|
|
Assert.IsTrue(XNARect.Empty.IsEmpty);
|
|
Assert.IsTrue(ANXRect.Empty.IsEmpty);
|
|
}
|
|
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void Left(int x1, int y1, int w1, int h1)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
|
|
int xnaR = xna.Left;
|
|
int anxR = anx.Left;
|
|
Assert.AreEqual(xnaR, anxR);
|
|
}
|
|
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void Location(int x1, int y1, int w1, int h1)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
|
|
int xnaRX = xna.Location.X;
|
|
int anxRX = anx.Location.X;
|
|
|
|
int xnaRY = xna.Location.Y;
|
|
int anxRY = anx.Location.Y;
|
|
Assert.AreEqual(xnaRX, anxRX);
|
|
Assert.AreEqual(xnaRY, anxRY);
|
|
}
|
|
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void Right(int x1, int y1, int w1, int h1)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
|
|
int xnaR = xna.Right;
|
|
int anxR = anx.Right;
|
|
Assert.AreEqual(xnaR, anxR);
|
|
}
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void Top(int x1, int y1, int w1, int h1)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
|
|
int xnaR = xna.Top;
|
|
int anxR = anx.Top;
|
|
Assert.AreEqual(xnaR, anxR);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region constructors
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void Constructor(int x1, int y1, int w1, int h1)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
AssertHelper.ConvertEquals(xna, anx, "Constructor");
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region public methods
|
|
[Test, TestCaseSource("ninefloats6")]
|
|
public void ContainsPoint(int x1, int y1, int w1, int h1, int u, int v, int nop1, int nop2)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
bool anxR = anx.Contains(u, v);
|
|
bool xnaR = xna.Contains(u, v);
|
|
Assert.AreEqual(xnaR, anxR);
|
|
}
|
|
|
|
|
|
[Test, TestCaseSource("ninefloats6")]
|
|
public void ContainsRect(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
XNARect xna2 = new XNARect(x2, y2, w2, h2);
|
|
ANXRect anx2 = new ANXRect(x2, y2, w2, h2);
|
|
|
|
bool xnaR = xna.Contains(xna2);
|
|
bool anxR = anx.Contains(anx2);
|
|
|
|
Assert.AreEqual(xnaR, anxR);
|
|
}
|
|
|
|
|
|
|
|
[Test, TestCaseSource("ninefloats")]
|
|
public void getHashCode(int x1, int y1, int w1, int h1)
|
|
{
|
|
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
|
|
Assert.AreEqual(xna.GetHashCode(), anx.GetHashCode());
|
|
}
|
|
|
|
|
|
[Test, TestCaseSource("ninefloats6")]
|
|
public void Inflate(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
|
|
xna.Inflate(x2, y2);
|
|
anx.Inflate(x2, y2);
|
|
|
|
AssertHelper.ConvertEquals(xna, anx, "Inflate");
|
|
|
|
}
|
|
[Test, TestCaseSource("ninefloats6")]
|
|
public void Intersects(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
XNARect xna2 = new XNARect(x2, y2, w2, h2);
|
|
ANXRect anx2 = new ANXRect(x2, y2, w2, h2);
|
|
Assert.AreEqual(xna.Intersects(xna2), anx.Intersects(anx2));
|
|
}
|
|
|
|
|
|
[Test, TestCaseSource("ninefloats6")]
|
|
public void Offset(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
|
|
xna.Offset(x2, y2);
|
|
anx.Offset(x2, y2);
|
|
|
|
AssertHelper.ConvertEquals(xna, anx, "Offset");
|
|
|
|
}
|
|
|
|
|
|
[Test, TestCaseSource("ninefloats6")]
|
|
public void IntersectStatic(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
XNARect xna2 = new XNARect(x2, y2, w2, h2);
|
|
ANXRect anx2 = new ANXRect(x2, y2, w2, h2);
|
|
|
|
AssertHelper.ConvertEquals(XNARect.Intersect(xna, xna2), ANXRect.Intersect(anx, anx2), "Intersection");
|
|
}
|
|
|
|
|
|
[Test, TestCaseSource("ninefloats6")]
|
|
public void Union(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
XNARect xna2 = new XNARect(x2, y2, w2, h2);
|
|
ANXRect anx2 = new ANXRect(x2, y2, w2, h2);
|
|
|
|
AssertHelper.ConvertEquals(XNARect.Union(xna, xna2), ANXRect.Union(anx, anx2), "Union");
|
|
}
|
|
|
|
|
|
[Test, TestCaseSource("ninefloats6")]
|
|
public void Equals(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
|
|
{
|
|
XNARect xna = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx = new ANXRect(x1, y1, w1, h1);
|
|
XNARect xna1 = new XNARect(x1, y1, w1, h1);
|
|
ANXRect anx1 = new ANXRect(x1, y1, w1, h1);
|
|
XNARect xna2 = new XNARect(x1 + 1, y1 + 1, w1 + 1, h1 + 1);
|
|
ANXRect anx2 = new ANXRect(x1 + 1, y1 + 1, w1 + 1, h1 + 1);
|
|
|
|
Assert.IsTrue(xna.Equals(xna1));
|
|
Assert.IsTrue(anx.Equals(anx1));
|
|
|
|
|
|
Assert.IsFalse(xna.Equals(xna2));
|
|
Assert.IsFalse(anx.Equals(anx2));
|
|
}
|
|
#endregion
|
|
}
|
|
}
|