add MouseStateTest.cs

some other test are modified
This commit is contained in:
SND\rene87_cp 2012-01-19 12:13:42 +00:00
parent 8ff04fef2e
commit 9907d2c740
8 changed files with 294 additions and 17 deletions

View File

@ -71,6 +71,7 @@
<Compile Include="Strukturen\Input\GamePadTriggersTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Strukturen\Input\KeyboardStateTest.cs" />
<Compile Include="Strukturen\Input\MouseStateTest.cs" />
<Compile Include="Strukturen\Storage\StorageContainerTest.cs" />
<Compile Include="Strukturen\Storage\StorageDeviceTest.cs" />
<Compile Include="Strukturen\BoundingBoxTest.cs" />

View File

@ -210,6 +210,15 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
AssertHelper.ConvertEquals(xna.Equals(xna2), anx.Equals(anx2), "Equals");
}
[TestCaseSource("buttonSample")]
public void Equals2(int buttons)
{
XNAGamePadButtons xna = new XNAGamePadButtons((XNAButtons)buttons);
ANXGamePadButtons anx = new ANXGamePadButtons((ANXButtons)buttons);
AssertHelper.ConvertEquals(xna.Equals(null), anx.Equals(null), "Equals2");
}
[TestCaseSource("buttonSample")]
public void op_Equality(int buttons)
{

View File

@ -174,6 +174,15 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
}
}
[TestCaseSource("Stats16")]
public void Equal3(ANXButtonState upValue, ANXButtonState downValue, ANXButtonState leftValue, ANXButtonState rightValue, XNAButtonState upValue2, XNAButtonState downValue2, XNAButtonState leftValue2, XNAButtonState rightValue2)
{
ANXGamePadDPad anx = new ANXGamePadDPad(upValue, downValue, leftValue, rightValue);
XNAGamePadDPad xna = new XNAGamePadDPad(upValue2, downValue2, leftValue2, rightValue2);
AssertHelper.ConvertEquals(xna.Equals(null), anx.Equals(null), "Equal3");
}
[TestCaseSource("Stats16")]
public void OperatorNoEqual(ANXButtonState upValue, ANXButtonState downValue, ANXButtonState leftValue, ANXButtonState rightValue, XNAButtonState upValue2, XNAButtonState downValue2, XNAButtonState leftValue2, XNAButtonState rightValue2)
{
ANXGamePadDPad anx = new ANXGamePadDPad(upValue, downValue, leftValue, rightValue);

View File

@ -78,6 +78,7 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
new object[] { DataFactory.RandomFloat, DataFactory.RandomFloat,DataFactory.RandomFloat, DataFactory.RandomFloat},
new object[]{-2,-2,-2,-2}
};
#endregion
[TestCaseSource("twofloats")]
public void Left(float leftX, float leftY,float rightX,float rightY)
{
@ -118,6 +119,13 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
AssertHelper.ConvertEquals(xna.Equals(xna2), anx.Equals(anx2), "Equals2");
}
[TestCaseSource("twofloats")]
public void Equals3(float leftX, float leftY, float rightX, float rightY)
{
ANXGamePadThumbSticks anx = new ANXGamePadThumbSticks(new ANXVector2(leftX, leftY), new ANXVector2(rightX, rightY));
XNAGamePadThumbSticks xna = new XNAGamePadThumbSticks(new XNAVector2(leftX, leftY), new XNAVector2(rightX, rightY));
AssertHelper.ConvertEquals(xna.Equals(null), anx.Equals(null), "Equals3");
}
[TestCaseSource("twofloats")]
public void NotEquals(float leftX, float leftY,float rightX,float rightY)
{
ANXGamePadThumbSticks anx = new ANXGamePadThumbSticks(new ANXVector2(leftX,leftY),new ANXVector2(rightX,rightY));
@ -130,6 +138,6 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
XNAGamePadThumbSticks xna2 = new XNAGamePadThumbSticks(new XNAVector2(leftX, leftY), new XNAVector2(rightX, rightY));
AssertHelper.ConvertEquals(xna != xna2, anx != anx2, "NotEquals");
}
#endregion
}
}

View File

@ -111,6 +111,13 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
AssertHelper.ConvertEquals(xna.Equals(xna2), anx.Equals(anx2), "Equals2");
}
[TestCaseSource("twofloats")]
public void Equals3(float leftTrigger, float rightTrigger)
{
ANXGamePadTriggers anx = new ANXGamePadTriggers(leftTrigger, rightTrigger);
XNAGamePadTriggers xna = new XNAGamePadTriggers(leftTrigger, rightTrigger);
AssertHelper.ConvertEquals(xna.Equals(null), anx.Equals(null), "Equals3");
}
[TestCaseSource("twofloats")]
public void NotEquals(float leftTrigger, float rightTrigger)
{
ANXGamePadTriggers anx = new ANXGamePadTriggers(leftTrigger, rightTrigger);

View File

@ -224,6 +224,8 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
{
new int[]{9,32,33,34,35,36,37,38,39,40},
new int[]{9,9,9,34,35,36,37,38,39,40},
new int[]{9,42,9,34,35,36,37,38,39,40},
new int[]{9,42,43,34,35,36,37,38,39,40},
};
#endregion
@ -271,6 +273,44 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
AssertHelper.ConvertEquals(xna == xna2, anx == anx2, "opequal");
}
[TestCaseSource("Key10")]
public void Equals(int[] key)
{
ANXKeys[] anxkey = new ANXKeys[10];
XNAKeys[] xnakey = new XNAKeys[10];
for (int i = 0; i < key.Length; i++)
{
anxkey[i] = (ANXKeys)key[i];
xnakey[i] = (XNAKeys)key[i];
}
ANXKeyboardState anx = new ANXKeyboardState(anxkey);
XNAKeyboardState xna = new XNAKeyboardState(xnakey);
ANXKeyboardState anx2 = new ANXKeyboardState(anxkey);
XNAKeyboardState xna2 = new XNAKeyboardState(xnakey);
AssertHelper.ConvertEquals(xna.Equals(xna2), anx.Equals(anx2), "Equals");
}
[TestCaseSource("Key10")]
public void Equals2(int[] key)
{
ANXKeys[] anxkey = new ANXKeys[10];
XNAKeys[] xnakey = new XNAKeys[10];
for (int i = 0; i < key.Length; i++)
{
anxkey[i] = (ANXKeys)key[i];
xnakey[i] = (XNAKeys)key[i];
}
ANXKeyboardState anx = new ANXKeyboardState(anxkey);
XNAKeyboardState xna = new XNAKeyboardState(xnakey);
AssertHelper.ConvertEquals(xna.Equals(null), anx.Equals(null), "Equals2");
}
[TestCaseSource("Key10")]
public void opEqual2(int[] key)
{
@ -350,5 +390,23 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
AssertHelper.ConvertEquals(xna.GetPressedKeys(), anx.GetPressedKeys(), "GetPressedKeys");
}
[TestCaseSource("Key10")]
public void KeyState(int[] key)
{
ANXKeys[] anxkey = new ANXKeys[10];
XNAKeys[] xnakey = new XNAKeys[10];
for (int i = 0; i < key.Length; i++)
{
anxkey[i] = (ANXKeys)key[i];
xnakey[i] = (XNAKeys)key[i];
}
ANXKeyboardState anx = new ANXKeyboardState(anxkey);
XNAKeyboardState xna = new XNAKeyboardState(xnakey);
AssertHelper.ConvertEquals(xna[(XNAKeys)9]==Microsoft.Xna.Framework.Input.KeyState.Down, anx[(ANXKeys)9]==ANX.Framework.Input.KeyState.Down, "KeyState");
}
}
}

View File

@ -0,0 +1,200 @@
#region Using Statements
using System;
using System.IO;
using ANX.Framework.NonXNA;
using NUnit.Framework;
#endregion // Using Statements
using XNAMouseState = Microsoft.Xna.Framework.Input.MouseState;
using ANXMouseState = ANX.Framework.Input.MouseState;
using XNAButtonState = Microsoft.Xna.Framework.Input.ButtonState;
using ANXButtonState = ANX.Framework.Input.ButtonState;
#region License
//
// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
//
// This file is released under the Ms-PL license.
//
//
//
// Microsoft Public License (Ms-PL)
//
// This license governs use of the accompanying software. If you use the software, you accept this license.
// If you do not accept the license, do not use the software.
//
// 1.Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning
// here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
//
// 2.Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
// or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in
// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed
// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution
// in the software or derivative works of the contribution in the software.
//
// 3.Conditions and Limitations
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
// patent license from such contributor to the software ends automatically.
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
// notices that are present in the software.
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
// object code form, you may only do so under a license that complies with this license.
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
#endregion // License
namespace ANX.Framework.TestCenter.Strukturen.Input
{
[TestFixture]
class MouseStateTest
{
#region TestCase
static object[] case1 =
{
new int[]{DataFactory.RandomIntValueMinMax(0,int.MaxValue),DataFactory.RandomIntValueMinMax(0,int.MaxValue),DataFactory.RandomIntValueMinMax(int.MinValue,int.MaxValue),DataFactory.RandomIntValueMinMax(0,2),DataFactory.RandomIntValueMinMax(0,2),DataFactory.RandomIntValueMinMax(0,2),DataFactory.RandomIntValueMinMax(0,2),DataFactory.RandomIntValueMinMax(0,2)},
};
#endregion
[TestCaseSource("case1")]
public void LeftButton(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna= new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.LeftButton == XNAButtonState.Pressed, anx.LeftButton == ANXButtonState.Pressed, "LeftButton");
}
[TestCaseSource("case1")]
public void MiddleButton(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.MiddleButton == XNAButtonState.Pressed, anx.MiddleButton == ANXButtonState.Pressed, "MiddleButton");
}
[TestCaseSource("case1")]
public void RightButton(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.RightButton == XNAButtonState.Pressed, anx.RightButton == ANXButtonState.Pressed, "RightButton");
}
[TestCaseSource("case1")]
public void XButton1(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.XButton1 == XNAButtonState.Pressed, anx.XButton1 == ANXButtonState.Pressed, "XButton1");
}
[TestCaseSource("case1")]
public void XButton2(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.XButton2 == XNAButtonState.Pressed, anx.XButton2 == ANXButtonState.Pressed, "XButton2");
}
[TestCaseSource("case1")]
public void ScrollWheelValue(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.ScrollWheelValue, anx.ScrollWheelValue, "ScrollWheelValue");
}
[TestCaseSource("case1")]
public void X(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.X, anx.X, "X");
}
[TestCaseSource("case1")]
public void Y(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.Y, anx.Y, "Y");
}
[TestCaseSource("case1")]
public void OpEqual(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
ANXMouseState anx2 = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna2 = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna == xna2, anx == anx2, "OpEqual");
}
[TestCaseSource("case1")]
public void Equals(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
ANXMouseState anx2 = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna2 = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.Equals(xna2), anx.Equals(anx2), "Equals");
}
[TestCaseSource("case1")]
public void Equals2(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
ANXMouseState anx2 = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna2 = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.Equals(null), anx.Equals(null), "Equals2");
}
[TestCaseSource("case1")]
public void OpUnEqual(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
ANXMouseState anx2 = new ANXMouseState(input[1], input[0], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna2 = new XNAMouseState(input[1], input[0], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna != xna2, anx != anx2, "OpUnEqual");
}
[TestCaseSource("case1")]
public void ToString(int[] input)
{
ANXMouseState anx = new ANXMouseState(input[0], input[1], input[2], (ANXButtonState)input[3], (ANXButtonState)input[4], (ANXButtonState)input[5], (ANXButtonState)input[6], (ANXButtonState)input[7]);
XNAMouseState xna = new XNAMouseState(input[0], input[1], input[2], (XNAButtonState)input[3], (XNAButtonState)input[4], (XNAButtonState)input[5], (XNAButtonState)input[6], (XNAButtonState)input[7]);
AssertHelper.ConvertEquals(xna.ToString(), anx.ToString(), "ToString");
}
}
}

View File

@ -94,22 +94,7 @@ namespace ANX.Framework.Input
{
if (obj != null && obj.GetType() == typeof(KeyboardState))
{
KeyboardState other = (KeyboardState)obj;
if (keyState.Length != other.keyState.Length)
{
return false;
}
for (int i = 0; i < keyState.Length; i++)
{
if (this.keyState[i] != other.keyState[i])
{
return false;
}
}
return true;
return this == (KeyboardState)obj;
}
return false;