add DataFactory.RandomIntValueMinMax(int min, int max)
add AssertHelper.ConvertEquals(XNAStorageContainer xna, ANXStorageContainer anx, String test) add more tests to StorageDeviceTest
This commit is contained in:
parent
da7a0029a6
commit
89b65cc2be
@ -136,6 +136,12 @@ using ANXMatrix = ANX.Framework.Matrix;
|
||||
using XNAQuaternion = Microsoft.Xna.Framework.Quaternion;
|
||||
using ANXQuaternion = ANX.Framework.Quaternion;
|
||||
|
||||
using XNAStorageDevice = Microsoft.Xna.Framework.Storage.StorageDevice;
|
||||
using ANXStorageDevice = ANX.Framework.Storage.StorageDevice;
|
||||
|
||||
using XNAStorageContainer = Microsoft.Xna.Framework.Storage.StorageContainer;
|
||||
using ANXStorageContainer = ANX.Framework.Storage.StorageContainer;
|
||||
|
||||
#endregion // Datatype usings
|
||||
|
||||
namespace ANX.Framework.TestCenter
|
||||
@ -704,5 +710,34 @@ namespace ANX.Framework.TestCenter
|
||||
Assert.Fail(String.Format("{0} failed: xna({1}) anx({2})", test, xna.ToString(), anx.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void ConvertEquals(XNAStorageDevice xna, ANXStorageDevice anx, String test)
|
||||
{
|
||||
if (CompareStorageDevice(xna, anx))
|
||||
{
|
||||
Assert.Pass(test + " passed");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Fail(String.Format("{0} failed: xna({1}) anx({2})", test, xna.ToString(), anx.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CompareStorageDevice(XNAStorageDevice xna, ANXStorageDevice anx)
|
||||
{
|
||||
return (xna.FreeSpace == anx.FreeSpace) && (xna.IsConnected == anx.IsConnected) && (xna.TotalSpace == anx.TotalSpace);
|
||||
}
|
||||
|
||||
public static void ConvertEquals(XNAStorageContainer xna, ANXStorageContainer anx, String test)
|
||||
{
|
||||
if ((CompareStorageDevice(xna.StorageDevice, anx.StorageDevice))&&(xna.IsDisposed==anx.IsDisposed)&&(xna.DisplayName==anx.DisplayName))
|
||||
{
|
||||
Assert.Pass(test + " passed");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Fail(String.Format("{0} failed: xna({1}) anx({2})", test, xna.ToString(), anx.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,5 +103,10 @@ namespace ANX.Framework.TestCenter
|
||||
{
|
||||
return (float)r.Next((int)min, (int)max) * (float)r.NextDouble();
|
||||
}
|
||||
|
||||
public static int RandomIntValueMinMax(int min, int max)
|
||||
{
|
||||
return r.Next(min, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ using XNAStorageDevice = Microsoft.Xna.Framework.Storage.StorageDevice;
|
||||
using XNAStorageContainer = Microsoft.Xna.Framework.Storage.StorageContainer;
|
||||
using XNAStorageDeviceNotConnectedException = Microsoft.Xna.Framework.Storage.StorageDeviceNotConnectedException;
|
||||
using XNAPlayerIndex = Microsoft.Xna.Framework.PlayerIndex;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
|
||||
@ -65,10 +66,10 @@ using XNAPlayerIndex = Microsoft.Xna.Framework.PlayerIndex;
|
||||
#endregion // License
|
||||
namespace ANX.Framework.TestCenter.Storage
|
||||
{
|
||||
[TestFixture]
|
||||
[TestFixture]
|
||||
class StorageDeviceTest
|
||||
{
|
||||
|
||||
|
||||
static object[] twoplayer =
|
||||
{
|
||||
new object[]{XNAPlayerIndex.One, ANXPlayerIndex.One},
|
||||
@ -76,7 +77,13 @@ namespace ANX.Framework.TestCenter.Storage
|
||||
new object[]{XNAPlayerIndex.Three, ANXPlayerIndex.Three},
|
||||
new object[]{XNAPlayerIndex.Four, ANXPlayerIndex.Four},
|
||||
};
|
||||
|
||||
static object[] twoint =
|
||||
{
|
||||
new object[]{DataFactory.RandomIntValueMinMax(0,int.MaxValue), DataFactory.RandomIntValueMinMax(0,int.MaxValue)},
|
||||
new object[]{DataFactory.RandomIntValueMinMax(0,int.MaxValue), DataFactory.RandomIntValueMinMax(0,int.MaxValue)},
|
||||
new object[]{DataFactory.RandomIntValueMinMax(0,int.MaxValue), DataFactory.RandomIntValueMinMax(0,int.MaxValue)},
|
||||
new object[]{DataFactory.RandomIntValueMinMax(0,int.MaxValue), DataFactory.RandomIntValueMinMax(0,int.MaxValue)}
|
||||
};
|
||||
[TestCaseSource("twoplayer")]
|
||||
public void BeginShowSelector(XNAPlayerIndex xnaplayer, ANXPlayerIndex anxplayer)
|
||||
{
|
||||
@ -86,23 +93,83 @@ namespace ANX.Framework.TestCenter.Storage
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
XNAStorageDevice xnadevice = XNAStorageDevice.EndShowSelector(xnaresult);
|
||||
if (xnadevice != null && xnadevice.IsConnected)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IAsyncResult anxresult = ANXStorageDevice.BeginShowSelector(anxplayer, null, null);
|
||||
while (!anxresult.IsCompleted)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
ANXStorageDevice anxdevice = ANXStorageDevice.EndShowSelector(xnaresult);
|
||||
if (anxdevice != null && anxdevice.IsConnected)
|
||||
{
|
||||
ANXStorageDevice anxdevice = ANXStorageDevice.EndShowSelector(anxresult);
|
||||
|
||||
AssertHelper.ConvertEquals(xnadevice, anxdevice, "BeginShowSelector");
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BeginShowSelector2()
|
||||
{
|
||||
IAsyncResult xnaresult = XNAStorageDevice.BeginShowSelector(null, null);
|
||||
while (!xnaresult.IsCompleted)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
|
||||
AssertHelper.ConvertEquals(xnaresult.ToString(), anxresult.ToString(), "BeginShowSelector");
|
||||
XNAStorageDevice xnadevice = XNAStorageDevice.EndShowSelector(xnaresult);
|
||||
|
||||
IAsyncResult anxresult = ANXStorageDevice.BeginShowSelector(null, null);
|
||||
while (!anxresult.IsCompleted)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
ANXStorageDevice anxdevice = ANXStorageDevice.EndShowSelector(anxresult);
|
||||
|
||||
AssertHelper.ConvertEquals(xnadevice, anxdevice, "BeginShowSelector2");
|
||||
|
||||
}
|
||||
|
||||
[TestCaseSource("twoint")]
|
||||
public void BeginShowSelector3(int one, int two)
|
||||
{
|
||||
IAsyncResult xnaresult = XNAStorageDevice.BeginShowSelector(one, two, null, null);
|
||||
while (!xnaresult.IsCompleted)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
XNAStorageDevice xnadevice = XNAStorageDevice.EndShowSelector(xnaresult);
|
||||
|
||||
IAsyncResult anxresult = ANXStorageDevice.BeginShowSelector(one, two, null, null);
|
||||
while (!anxresult.IsCompleted)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
ANXStorageDevice anxdevice = ANXStorageDevice.EndShowSelector(anxresult);
|
||||
|
||||
AssertHelper.ConvertEquals(xnadevice, anxdevice, "BeginShowSelector3");
|
||||
|
||||
}
|
||||
[TestCaseSource("twoplayer")]
|
||||
public void BeginOpenContainer(XNAPlayerIndex xnaplayer, ANXPlayerIndex anxplayer)
|
||||
{
|
||||
IAsyncResult xnaresult = XNAStorageDevice.BeginShowSelector(xnaplayer, null, null);
|
||||
xnaresult.AsyncWaitHandle.WaitOne();
|
||||
XNAStorageDevice xnadevice = XNAStorageDevice.EndShowSelector(xnaresult);
|
||||
IAsyncResult xnaresult2 = xnadevice.BeginOpenContainer("StorageTest", null, null);
|
||||
while (!xnaresult2.IsCompleted)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
XNAStorageContainer xnacontainer = xnadevice.EndOpenContainer(xnaresult2);
|
||||
xnaresult2.AsyncWaitHandle.Close();
|
||||
|
||||
IAsyncResult anxresult = ANXStorageDevice.BeginShowSelector(anxplayer, null, null);
|
||||
anxresult.AsyncWaitHandle.WaitOne();
|
||||
ANXStorageDevice anxdevice = ANXStorageDevice.EndShowSelector(anxresult);
|
||||
IAsyncResult anxresult2 = anxdevice.BeginOpenContainer("StorageTest", null, null);
|
||||
anxresult2.AsyncWaitHandle.WaitOne();
|
||||
ANXStorageContainer anxcontainer = anxdevice.EndOpenContainer(anxresult2);
|
||||
anxresult2.AsyncWaitHandle.Close();
|
||||
|
||||
|
||||
AssertHelper.ConvertEquals(xnacontainer, anxcontainer, "BeginOpenContainer");
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user