Added a test for comparison of all xna and anx enums and fixed some wrong enum basetypes

This commit is contained in:
SND\AstrorEnales_cp 2012-10-14 09:43:58 +00:00 committed by Konstantin Koch
parent e74616755c
commit 1aa7d3fe37
37 changed files with 130 additions and 30 deletions

View File

@ -63,6 +63,7 @@
<Compile Include="ReflectionLearningTests.cs" />
<Compile Include="Strukturen\CurveKeyCollectionTest.cs" />
<Compile Include="Strukturen\CurveKeyTest.cs" />
<Compile Include="Strukturen\EnumValidationTest.cs" />
<Compile Include="Strukturen\EventArgsTest.cs" />
<Compile Include="Strukturen\GameServiceContainerTest.cs" />
<Compile Include="Strukturen\Graphics\PackedVector\Alpha8Test.cs" />

View File

@ -63,6 +63,7 @@
<Compile Include="ReflectionLearningTests.cs" />
<Compile Include="Strukturen\CurveKeyCollectionTest.cs" />
<Compile Include="Strukturen\CurveKeyTest.cs" />
<Compile Include="Strukturen\EnumValidationTest.cs" />
<Compile Include="Strukturen\EventArgsTest.cs" />
<Compile Include="Strukturen\GameServiceContainerTest.cs" />
<Compile Include="Strukturen\Graphics\PackedVector\Alpha8Test.cs" />

View File

@ -64,6 +64,7 @@
<Compile Include="ReflectionLearningTests.cs" />
<Compile Include="Strukturen\CurveKeyCollectionTest.cs" />
<Compile Include="Strukturen\CurveKeyTest.cs" />
<Compile Include="Strukturen\EnumValidationTest.cs" />
<Compile Include="Strukturen\EventArgsTest.cs" />
<Compile Include="Strukturen\GameServiceContainerTest.cs" />
<Compile Include="Strukturen\Graphics\PackedVector\Alpha8Test.cs" />

View File

@ -65,6 +65,7 @@
<Compile Include="ReflectionLearningTests.cs" />
<Compile Include="Strukturen\CurveKeyCollectionTest.cs" />
<Compile Include="Strukturen\CurveKeyTest.cs" />
<Compile Include="Strukturen\EnumValidationTest.cs" />
<Compile Include="Strukturen\EventArgsTest.cs" />
<Compile Include="Strukturen\GameServiceContainerTest.cs" />
<Compile Include="Strukturen\Graphics\PackedVector\Alpha8Test.cs" />

View File

@ -0,0 +1,89 @@
using System;
using ANX.Framework.Audio;
using ANX.Framework.Graphics;
using NUnit.Framework;
using ANX.Framework.Input;
using ANX.Framework.Media;
// 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
namespace ANX.Framework.TestCenter.Strukturen
{
class EnumValidationTest
{
private static readonly object[] EnumPairs =
{
new object[] { typeof(Microsoft.Xna.Framework.ContainmentType), typeof(ContainmentType) },
new object[] { typeof(Microsoft.Xna.Framework.CurveContinuity), typeof(CurveContinuity) },
new object[] { typeof(Microsoft.Xna.Framework.CurveLoopType), typeof(CurveLoopType) },
new object[] { typeof(Microsoft.Xna.Framework.CurveTangent), typeof(CurveTangent) },
new object[] { typeof(Microsoft.Xna.Framework.DisplayOrientation), typeof(DisplayOrientation) },
new object[] { typeof(Microsoft.Xna.Framework.PlaneIntersectionType), typeof(PlaneIntersectionType) },
new object[] { typeof(Microsoft.Xna.Framework.PlayerIndex), typeof(PlayerIndex) },
new object[] { typeof(Microsoft.Xna.Framework.Audio.AudioChannels), typeof(AudioChannels) },
new object[] { typeof(Microsoft.Xna.Framework.Audio.MicrophoneState), typeof(MicrophoneState) },
new object[] { typeof(Microsoft.Xna.Framework.Audio.SoundState), typeof(SoundState) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.Blend), typeof(Blend) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.BlendFunction), typeof(BlendFunction) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.BufferUsage), typeof(BufferUsage) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.ClearOptions), typeof(ClearOptions) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.ColorWriteChannels), typeof(ColorWriteChannels) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.CompareFunction), typeof(CompareFunction) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.CubeMapFace), typeof(CubeMapFace) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.CullMode), typeof(CullMode) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.DepthFormat), typeof(DepthFormat) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.EffectParameterClass), typeof(EffectParameterClass) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.EffectParameterType), typeof(EffectParameterType) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.FillMode), typeof(FillMode) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.GraphicsDeviceStatus), typeof(GraphicsDeviceStatus) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.GraphicsProfile), typeof(GraphicsProfile) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.IndexElementSize), typeof(IndexElementSize) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.PresentInterval), typeof(PresentInterval) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.PrimitiveType), typeof(PrimitiveType) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.RenderTargetUsage), typeof(RenderTargetUsage) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.SetDataOptions), typeof(SetDataOptions) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.SpriteEffects), typeof(SpriteEffects) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.SpriteSortMode), typeof(SpriteSortMode) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.StencilOperation), typeof(StencilOperation) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.SurfaceFormat), typeof(SurfaceFormat) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.TextureAddressMode), typeof(TextureAddressMode) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.TextureFilter), typeof(TextureFilter) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.VertexElementFormat), typeof(VertexElementFormat) },
new object[] { typeof(Microsoft.Xna.Framework.Graphics.VertexElementUsage), typeof(VertexElementUsage) },
new object[] { typeof(Microsoft.Xna.Framework.Input.ButtonState), typeof(ButtonState) },
new object[] { typeof(Microsoft.Xna.Framework.Input.Buttons), typeof(Buttons) },
new object[] { typeof(Microsoft.Xna.Framework.Input.GamePadType), typeof(GamePadType) },
new object[] { typeof(Microsoft.Xna.Framework.Input.KeyState), typeof(KeyState) },
new object[] { typeof(Microsoft.Xna.Framework.Input.Keys), typeof(Keys) },
new object[] { typeof(Microsoft.Xna.Framework.Media.MediaSourceType), typeof(MediaSourceType) },
new object[] { typeof(Microsoft.Xna.Framework.Media.MediaState), typeof(MediaState) },
};
[TestCaseSource("EnumPairs")]
public void CompareEnums(Type first, Type second)
{
string[] xnaNames = Enum.GetNames(first);
string[] anxNames = Enum.GetNames(second);
for(int index = 0; index < xnaNames.Length; index++)
{
Assert.AreEqual(xnaNames[index], anxNames[index]);
Type xnaUnderlyingType = Enum.GetUnderlyingType(first);
Type anxUnderlyingType = Enum.GetUnderlyingType(second);
Assert.AreEqual(xnaUnderlyingType, anxUnderlyingType);
object xnaValue = Enum.Parse(first, xnaNames[index]);
object anxValue = Enum.Parse(second, anxNames[index]);
if (xnaUnderlyingType == typeof(byte))
Assert.AreEqual((byte)xnaValue, (byte)anxValue);
else
Assert.AreEqual((int)xnaValue, (int)anxValue);
}
}
}
}

View File

@ -490,7 +490,7 @@ namespace ANX.Framework
#region IEquatable implementation
public override bool Equals(Object obj)
{
return (obj is BoundingBox) ? this.Equals((BoundingBox)obj) : false;
return obj is BoundingBox && Equals((BoundingBox)obj);
}
public bool Equals(BoundingBox other)
{

View File

@ -2,7 +2,6 @@
using System;
using ANX.Framework.NonXNA.Development;
#endregion // Using Statements
// This file is part of the ANX.Framework created by the
@ -756,19 +755,12 @@ namespace ANX.Framework
public override bool Equals(Object obj)
{
var frustum = obj as BoundingFrustum;
if (frustum != null)
{
return this.Matrix == frustum.Matrix;
}
return false;
return frustum != null && this.Matrix == frustum.Matrix;
}
public bool Equals(BoundingFrustum other)
{
if (other != null)
{
return this.Matrix == other.Matrix;
}
return false;
return other != null && this.Matrix == other.Matrix;
}
#endregion

View File

@ -428,7 +428,7 @@ namespace ANX.Framework
#region IEquatable implementation
public override bool Equals(Object obj)
{
return (obj is BoundingSphere) ? this.Equals((BoundingSphere)obj) : false;
return obj is BoundingSphere && Equals((BoundingSphere)obj);
}
public bool Equals(BoundingSphere other)
{

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum Blend
{
One,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum BlendFunction
{
Add,

View File

@ -10,7 +10,7 @@ namespace ANX.Framework.Graphics
[Flags]
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum BufferUsage
{
None,

View File

@ -10,7 +10,7 @@ namespace ANX.Framework.Graphics
[Flags]
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum ClearOptions
{
DepthBuffer = 2,

View File

@ -10,7 +10,7 @@ namespace ANX.Framework.Graphics
[Flags]
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum ColorWriteChannels
{
All = 15,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum CompareFunction
{
Always,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum CubeMapFace
{
PositiveX,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum CullMode
{
None,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum DepthFormat
{
None,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum EffectParameterType
{
Void,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum FillMode
{
Solid,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum GraphicsDeviceStatus
{
Normal,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum GraphicsProfile
{
Reach,

View File

@ -7,7 +7,7 @@ namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
[TestState(TestStateAttribute.TestState.Tested)]
public enum IndexElementSize
{
SixteenBits,

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum RenderTargetUsage
{

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum SetDataOptions
{

View File

@ -9,6 +9,7 @@ namespace ANX.Framework.Graphics
{
[Flags]
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum SpriteEffects
{

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum SpriteSortMode
{

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum StencilOperation
{

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum SurfaceFormat
{

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum TextureAddressMode
{

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum TextureFilter
{

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum VertexElementFormat
{

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum VertexElementUsage
{

View File

@ -7,8 +7,9 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Input
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum ButtonState : byte
public enum ButtonState
{
Released,
Pressed

View File

@ -8,6 +8,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Input
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
[Flags]
public enum Buttons

View File

@ -7,8 +7,9 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Input
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum GamePadType : short
public enum GamePadType
{
Unknown,
GamePad,

View File

@ -7,6 +7,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Input
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum KeyState
{

View File

@ -7,8 +7,9 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Input
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public enum Keys : byte
public enum Keys
{
None = 0,
Back = 8,