Added full test sets for NetworkSessionProperties, PacketReader, PacketWriter and QualityOfService

This commit is contained in:
SND\AstrorEnales_cp 2012-10-14 12:17:15 +00:00 committed by Konstantin Koch
parent b661bba5f3
commit 7c88884f63
21 changed files with 722 additions and 97 deletions

View File

@ -39,6 +39,7 @@
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Xna.Framework.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="nunit.framework">
<HintPath>..\lib\NUnit-2.6.1\bin\nunit.framework.dll</HintPath>
@ -80,6 +81,10 @@
<Compile Include="Strukturen\Input\MouseTest.cs" />
<Compile Include="Strukturen\GameComponentCollectionTest.cs" />
<Compile Include="Strukturen\Media\MediaLibraryTests.cs" />
<Compile Include="Strukturen\Net\NetworkSessionPropertiesTest.cs" />
<Compile Include="Strukturen\Net\PacketReaderTest.cs" />
<Compile Include="Strukturen\Net\PacketWriterTest.cs" />
<Compile Include="Strukturen\Net\QualityOfServiceTest.cs" />
<Compile Include="Strukturen\Storage\StorageContainerTest.cs" />
<Compile Include="Strukturen\Storage\StorageDeviceTest.cs" />
<Compile Include="Strukturen\BoundingBoxTest.cs" />
@ -123,7 +128,6 @@
<Folder Include="Strukturen\Content\SystemTypeReaders\" />
<Folder Include="Strukturen\Input\MotionSensing\" />
<Folder Include="Strukturen\Input\Touch\" />
<Folder Include="Strukturen\Net\" />
<Folder Include="Strukturen\NonXNA\InputSystem\" />
<Folder Include="Strukturen\NonXNA\RenderSystem\" />
<Folder Include="Strukturen\NonXNA\SoundSystem\" />

View File

@ -39,6 +39,7 @@
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Xna.Framework.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="nunit.framework">
<HintPath>..\lib\NUnit-2.6.1\bin\nunit.framework.dll</HintPath>
@ -80,6 +81,10 @@
<Compile Include="Strukturen\Input\MouseTest.cs" />
<Compile Include="Strukturen\GameComponentCollectionTest.cs" />
<Compile Include="Strukturen\Media\MediaLibraryTests.cs" />
<Compile Include="Strukturen\Net\NetworkSessionPropertiesTest.cs" />
<Compile Include="Strukturen\Net\PacketReaderTest.cs" />
<Compile Include="Strukturen\Net\PacketWriterTest.cs" />
<Compile Include="Strukturen\Net\QualityOfServiceTest.cs" />
<Compile Include="Strukturen\Storage\StorageContainerTest.cs" />
<Compile Include="Strukturen\Storage\StorageDeviceTest.cs" />
<Compile Include="Strukturen\BoundingBoxTest.cs" />
@ -123,7 +128,6 @@
<Folder Include="Strukturen\Content\SystemTypeReaders\" />
<Folder Include="Strukturen\Input\MotionSensing\" />
<Folder Include="Strukturen\Input\Touch\" />
<Folder Include="Strukturen\Net\" />
<Folder Include="Strukturen\NonXNA\InputSystem\" />
<Folder Include="Strukturen\NonXNA\RenderSystem\" />
<Folder Include="Strukturen\NonXNA\SoundSystem\" />

View File

@ -39,6 +39,7 @@
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Xna.Framework.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="nunit.framework">
<HintPath>..\lib\NUnit-2.6.1\bin\nunit.framework.dll</HintPath>
@ -81,6 +82,10 @@
<Compile Include="Strukturen\Input\MouseTest.cs" />
<Compile Include="Strukturen\GameComponentCollectionTest.cs" />
<Compile Include="Strukturen\Media\MediaLibraryTests.cs" />
<Compile Include="Strukturen\Net\NetworkSessionPropertiesTest.cs" />
<Compile Include="Strukturen\Net\PacketReaderTest.cs" />
<Compile Include="Strukturen\Net\PacketWriterTest.cs" />
<Compile Include="Strukturen\Net\QualityOfServiceTest.cs" />
<Compile Include="Strukturen\Storage\StorageContainerTest.cs" />
<Compile Include="Strukturen\Storage\StorageDeviceTest.cs" />
<Compile Include="Strukturen\BoundingBoxTest.cs" />
@ -124,7 +129,6 @@
<Folder Include="Strukturen\Content\SystemTypeReaders\" />
<Folder Include="Strukturen\Input\MotionSensing\" />
<Folder Include="Strukturen\Input\Touch\" />
<Folder Include="Strukturen\Net\" />
<Folder Include="Strukturen\NonXNA\InputSystem\" />
<Folder Include="Strukturen\NonXNA\RenderSystem\" />
<Folder Include="Strukturen\NonXNA\SoundSystem\" />

View File

@ -41,6 +41,7 @@
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Xna.Framework.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=MSIL" />
<Reference Include="nunit.framework">
<HintPath>..\lib\NUnit-2.6.1\bin\nunit.framework.dll</HintPath>
@ -82,6 +83,10 @@
<Compile Include="Strukturen\Input\MouseTest.cs" />
<Compile Include="Strukturen\GameComponentCollectionTest.cs" />
<Compile Include="Strukturen\Media\MediaLibraryTests.cs" />
<Compile Include="Strukturen\Net\NetworkSessionPropertiesTest.cs" />
<Compile Include="Strukturen\Net\PacketReaderTest.cs" />
<Compile Include="Strukturen\Net\PacketWriterTest.cs" />
<Compile Include="Strukturen\Net\QualityOfServiceTest.cs" />
<Compile Include="Strukturen\Storage\StorageContainerTest.cs" />
<Compile Include="Strukturen\Storage\StorageDeviceTest.cs" />
<Compile Include="Strukturen\BoundingBoxTest.cs" />
@ -125,7 +130,6 @@
<Folder Include="Strukturen\Content\SystemTypeReaders\" />
<Folder Include="Strukturen\Input\MotionSensing\" />
<Folder Include="Strukturen\Input\Touch\" />
<Folder Include="Strukturen\Net\" />
<Folder Include="Strukturen\NonXNA\InputSystem\" />
<Folder Include="Strukturen\NonXNA\RenderSystem\" />
<Folder Include="Strukturen\NonXNA\SoundSystem\" />

View File

@ -1,6 +1,7 @@
using System;
using ANX.Framework.Audio;
using ANX.Framework.Graphics;
using ANX.Framework.Net;
using NUnit.Framework;
using ANX.Framework.Input;
using ANX.Framework.Media;
@ -62,6 +63,12 @@ namespace ANX.Framework.TestCenter.Strukturen
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) },
new object[] { typeof(Microsoft.Xna.Framework.Net.NetworkSessionEndReason), typeof(NetworkSessionEndReason) },
new object[] { typeof(Microsoft.Xna.Framework.Net.NetworkSessionJoinError), typeof(NetworkSessionJoinError) },
new object[] { typeof(Microsoft.Xna.Framework.Net.NetworkSessionState), typeof(NetworkSessionState) },
new object[] { typeof(Microsoft.Xna.Framework.Net.NetworkSessionType), typeof(NetworkSessionType) },
new object[] { typeof(Microsoft.Xna.Framework.Net.SendDataOptions), typeof(SendDataOptions) },
};
[TestCaseSource("EnumPairs")]

View File

@ -0,0 +1,181 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using XNANetworkSessionProperties = Microsoft.Xna.Framework.Net.NetworkSessionProperties;
using ANXNetworkSessionProperties = ANX.Framework.Net.NetworkSessionProperties;
// 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.Net
{
class NetworkSessionPropertiesTest
{
[Test]
public void Constructor()
{
var xna = new XNANetworkSessionProperties();
var anx = new ANXNetworkSessionProperties();
Assert.AreEqual(xna.Count, anx.Count);
}
[Test]
public void IndexAccessOutOfRange1()
{
var xna = new XNANetworkSessionProperties();
var anx = new ANXNetworkSessionProperties();
TestDelegate xnaDeleg = delegate { xna[15] = null; };
TestDelegate anxDeleg = delegate { anx[15] = null; };
AssertHelper.ConvertEquals(Assert.Throws<ArgumentOutOfRangeException>(xnaDeleg),
Assert.Throws<ArgumentOutOfRangeException>(anxDeleg), "IndexAccessOutOfRange");
}
[Test]
public void IndexAccessOutOfRange2()
{
var xna = new XNANetworkSessionProperties();
var anx = new ANXNetworkSessionProperties();
TestDelegate xnaDeleg = delegate { xna[-4] = null; };
TestDelegate anxDeleg = delegate { anx[-4] = null; };
AssertHelper.ConvertEquals(Assert.Throws<ArgumentOutOfRangeException>(xnaDeleg),
Assert.Throws<ArgumentOutOfRangeException>(anxDeleg), "IndexAccessOutOfRange");
}
[Test]
public void InitialValues()
{
var xna = new XNANetworkSessionProperties();
var anx = new ANXNetworkSessionProperties();
for (int index = 0; index < xna.Count; index++)
Assert.AreEqual(xna[index], anx[index]);
}
[Test]
public void IsReadOnly()
{
var xna = (IList<int?>)new XNANetworkSessionProperties();
var anx = (IList<int?>)new ANXNetworkSessionProperties();
AssertHelper.ConvertEquals(xna.IsReadOnly, anx.IsReadOnly, "IsReadOnly");
}
[Test]
public void AddNotSupported()
{
var xna = (IList<int?>)new XNANetworkSessionProperties();
var anx = (IList<int?>)new ANXNetworkSessionProperties();
TestDelegate xnaDeleg = () => xna.Add(null);
TestDelegate anxDeleg = () => anx.Add(null);
AssertHelper.ConvertEquals(Assert.Throws<NotSupportedException>(xnaDeleg),
Assert.Throws<NotSupportedException>(anxDeleg), "AddNotSupported");
}
[Test]
public void RemoveNotSupported()
{
var xna = (IList<int?>)new XNANetworkSessionProperties();
var anx = (IList<int?>)new ANXNetworkSessionProperties();
TestDelegate xnaDeleg = () => xna.Remove(null);
TestDelegate anxDeleg = () => anx.Remove(null);
AssertHelper.ConvertEquals(Assert.Throws<NotSupportedException>(xnaDeleg),
Assert.Throws<NotSupportedException>(anxDeleg), "RemoveNotSupported");
}
[Test]
public void RemoveAtNotSupported()
{
var xna = (IList<int?>)new XNANetworkSessionProperties();
var anx = (IList<int?>)new ANXNetworkSessionProperties();
TestDelegate xnaDeleg = () => xna.RemoveAt(1);
TestDelegate anxDeleg = () => anx.RemoveAt(1);
AssertHelper.ConvertEquals(Assert.Throws<NotSupportedException>(xnaDeleg),
Assert.Throws<NotSupportedException>(anxDeleg), "RemoveAtNotSupported");
}
[Test]
public void ClearNotSupported()
{
var xna = (IList<int?>)new XNANetworkSessionProperties();
var anx = (IList<int?>)new ANXNetworkSessionProperties();
TestDelegate xnaDeleg = xna.Clear;
TestDelegate anxDeleg = anx.Clear;
AssertHelper.ConvertEquals(Assert.Throws<NotSupportedException>(xnaDeleg),
Assert.Throws<NotSupportedException>(anxDeleg), "ClearNotSupported");
}
[Test]
public void InsertNotSupported()
{
var xna = (IList<int?>)new XNANetworkSessionProperties();
var anx = (IList<int?>)new ANXNetworkSessionProperties();
TestDelegate xnaDeleg = () => xna.Insert(1, null);
TestDelegate anxDeleg = () => anx.Insert(1, null);
AssertHelper.ConvertEquals(Assert.Throws<NotSupportedException>(xnaDeleg),
Assert.Throws<NotSupportedException>(anxDeleg), "InsertNotSupported");
}
[Test]
public void IndexOf()
{
var xna = (IList<int?>)new XNANetworkSessionProperties();
var anx = (IList<int?>)new ANXNetworkSessionProperties();
xna[6] = 15;
anx[6] = 15;
AssertHelper.ConvertEquals(xna.IndexOf(15), anx.IndexOf(15), "IndexOf");
}
[Test]
public void Contains()
{
var xna = (IList<int?>)new XNANetworkSessionProperties();
var anx = (IList<int?>)new ANXNetworkSessionProperties();
xna[6] = 15;
anx[6] = 15;
AssertHelper.ConvertEquals(xna.Contains(15), anx.Contains(15), "Contains");
}
[Test]
public void CopyTo()
{
var xna = (IList<int?>)new XNANetworkSessionProperties();
var anx = (IList<int?>)new ANXNetworkSessionProperties();
xna[6] = 15;
anx[6] = 15;
var xnaData = new int?[8];
var anxData = new int?[8];
xna.CopyTo(xnaData, 0);
anx.CopyTo(anxData, 0);
for (int index = 0; index < xnaData.Length; index++)
Assert.AreEqual(xnaData[index], anxData[index]);
Assert.AreEqual(xnaData[6], 15);
Assert.AreEqual(anxData[6], 15);
}
}
}

View File

@ -0,0 +1,197 @@
using System;
using System.IO;
using NUnit.Framework;
using XNAPacketReader = Microsoft.Xna.Framework.Net.PacketReader;
using ANXPacketReader = ANX.Framework.Net.PacketReader;
// 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.Net
{
class PacketReaderTest
{
[Test]
public void Constructor1()
{
var xna = new XNAPacketReader();
var anx = new ANXPacketReader();
Assert.AreEqual(xna.Length, anx.Length);
Assert.AreEqual(xna.Position, anx.Position);
}
[Test]
public void Constructor2()
{
var xna = new XNAPacketReader(256);
var anx = new ANXPacketReader(256);
Assert.AreEqual(((MemoryStream)xna.BaseStream).Capacity, ((MemoryStream)anx.BaseStream).Capacity);
}
[Test]
public void ReadVector2()
{
var xna = new XNAPacketReader();
var anx = new ANXPacketReader();
var xnaWriter = new BinaryWriter(xna.BaseStream);
var anxWriter = new BinaryWriter(anx.BaseStream);
xnaWriter.Write(4.5f);
xnaWriter.Write(1f);
anxWriter.Write(4.5f);
anxWriter.Write(1f);
xna.BaseStream.Position = 0;
anx.BaseStream.Position = 0;
AssertHelper.ConvertEquals(xna.ReadVector2(), anx.ReadVector2(), "ReadVector2");
}
[Test]
public void ReadVector3()
{
var xna = new XNAPacketReader();
var anx = new ANXPacketReader();
var xnaWriter = new BinaryWriter(xna.BaseStream);
var anxWriter = new BinaryWriter(anx.BaseStream);
xnaWriter.Write(4.5f);
xnaWriter.Write(1f);
xnaWriter.Write(0.4f);
anxWriter.Write(4.5f);
anxWriter.Write(1f);
anxWriter.Write(0.4f);
xna.BaseStream.Position = 0;
anx.BaseStream.Position = 0;
AssertHelper.ConvertEquals(xna.ReadVector3(), anx.ReadVector3(), "ReadVector3");
}
[Test]
public void ReadVector4()
{
var xna = new XNAPacketReader();
var anx = new ANXPacketReader();
var xnaWriter = new BinaryWriter(xna.BaseStream);
var anxWriter = new BinaryWriter(anx.BaseStream);
xnaWriter.Write(4.5f);
xnaWriter.Write(1f);
xnaWriter.Write(0.4f);
xnaWriter.Write(16f);
anxWriter.Write(4.5f);
anxWriter.Write(1f);
anxWriter.Write(0.4f);
anxWriter.Write(16f);
xna.BaseStream.Position = 0;
anx.BaseStream.Position = 0;
AssertHelper.ConvertEquals(xna.ReadVector4(), anx.ReadVector4(), "ReadVector4");
}
[Test]
public void ReadMatrix()
{
var xna = new XNAPacketReader();
var anx = new ANXPacketReader();
var xnaWriter = new BinaryWriter(xna.BaseStream);
var anxWriter = new BinaryWriter(anx.BaseStream);
Matrix mat = Matrix.CreateRotationY(0.1f);
xnaWriter.Write(mat.M11);
xnaWriter.Write(mat.M12);
xnaWriter.Write(mat.M13);
xnaWriter.Write(mat.M14);
xnaWriter.Write(mat.M21);
xnaWriter.Write(mat.M22);
xnaWriter.Write(mat.M23);
xnaWriter.Write(mat.M24);
xnaWriter.Write(mat.M31);
xnaWriter.Write(mat.M32);
xnaWriter.Write(mat.M33);
xnaWriter.Write(mat.M34);
xnaWriter.Write(mat.M41);
xnaWriter.Write(mat.M42);
xnaWriter.Write(mat.M43);
xnaWriter.Write(mat.M44);
anxWriter.Write(mat.M11);
anxWriter.Write(mat.M12);
anxWriter.Write(mat.M13);
anxWriter.Write(mat.M14);
anxWriter.Write(mat.M21);
anxWriter.Write(mat.M22);
anxWriter.Write(mat.M23);
anxWriter.Write(mat.M24);
anxWriter.Write(mat.M31);
anxWriter.Write(mat.M32);
anxWriter.Write(mat.M33);
anxWriter.Write(mat.M34);
anxWriter.Write(mat.M41);
anxWriter.Write(mat.M42);
anxWriter.Write(mat.M43);
anxWriter.Write(mat.M44);
xna.BaseStream.Position = 0;
anx.BaseStream.Position = 0;
AssertHelper.ConvertEquals(xna.ReadMatrix(), anx.ReadMatrix(), "ReadMatrix");
}
[Test]
public void ReadQuaternion()
{
var xna = new XNAPacketReader();
var anx = new ANXPacketReader();
var xnaWriter = new BinaryWriter(xna.BaseStream);
var anxWriter = new BinaryWriter(anx.BaseStream);
xnaWriter.Write(4.5f);
xnaWriter.Write(0.4f);
xnaWriter.Write(1f);
xnaWriter.Write(16f);
anxWriter.Write(4.5f);
anxWriter.Write(0.4f);
anxWriter.Write(1f);
anxWriter.Write(16f);
xna.BaseStream.Position = 0;
anx.BaseStream.Position = 0;
AssertHelper.ConvertEquals(xna.ReadQuaternion(), anx.ReadQuaternion(), "ReadQuaternion");
}
[Test]
public void ReadColor()
{
var xna = new XNAPacketReader();
var anx = new ANXPacketReader();
var xnaWriter = new BinaryWriter(xna.BaseStream);
var anxWriter = new BinaryWriter(anx.BaseStream);
xnaWriter.Write(Color.LightBlue.PackedValue);
anxWriter.Write(Color.LightBlue.PackedValue);
xna.BaseStream.Position = 0;
anx.BaseStream.Position = 0;
AssertHelper.ConvertEquals(xna.ReadColor(), anx.ReadColor(), "ReadColor");
}
}
}

View File

@ -0,0 +1,160 @@
using System;
using System.IO;
using NUnit.Framework;
using XNAPacketWriter = Microsoft.Xna.Framework.Net.PacketWriter;
using ANXPacketWriter = ANX.Framework.Net.PacketWriter;
// 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.Net
{
internal class PacketWriterTest
{
[Test]
public void Constructor1()
{
var xna = new XNAPacketWriter();
var anx = new ANXPacketWriter();
Assert.AreEqual(xna.Length, anx.Length);
Assert.AreEqual(xna.Position, anx.Position);
}
[Test]
public void Constructor2()
{
var xna = new XNAPacketWriter(256);
var anx = new ANXPacketWriter(256);
Assert.AreEqual(((MemoryStream)xna.BaseStream).Capacity, ((MemoryStream)anx.BaseStream).Capacity);
}
[Test]
public void WriteVector2()
{
var xna = new XNAPacketWriter();
var anx = new ANXPacketWriter();
xna.Write(new Microsoft.Xna.Framework.Vector2(15f, 3.5f));
anx.Write(new Vector2(15f, 3.5f));
Assert.AreEqual(xna.Length, anx.Length);
Assert.AreEqual(xna.Position, anx.Position);
xna.Position = 0;
anx.Position = 0;
var xnaReader = new BinaryReader(xna.BaseStream);
var anxReader = new BinaryReader(anx.BaseStream);
for (int index = 0; index < 2; index++)
Assert.AreEqual(xnaReader.ReadSingle(), anxReader.ReadSingle());
}
[Test]
public void WriteVector3()
{
var xna = new XNAPacketWriter();
var anx = new ANXPacketWriter();
xna.Write(new Microsoft.Xna.Framework.Vector3(15f, 3.5f, 0.1f));
anx.Write(new Vector3(15f, 3.5f, 0.1f));
Assert.AreEqual(xna.Length, anx.Length);
Assert.AreEqual(xna.Position, anx.Position);
xna.Position = 0;
anx.Position = 0;
var xnaReader = new BinaryReader(xna.BaseStream);
var anxReader = new BinaryReader(anx.BaseStream);
for (int index = 0; index < 3; index++)
Assert.AreEqual(xnaReader.ReadSingle(), anxReader.ReadSingle());
}
[Test]
public void WriteVector4()
{
var xna = new XNAPacketWriter();
var anx = new ANXPacketWriter();
xna.Write(new Microsoft.Xna.Framework.Vector4(15f, 3.5f, 0.1f, 1f));
anx.Write(new Vector4(15f, 3.5f, 0.1f, 1f));
Assert.AreEqual(xna.Length, anx.Length);
Assert.AreEqual(xna.Position, anx.Position);
xna.Position = 0;
anx.Position = 0;
var xnaReader = new BinaryReader(xna.BaseStream);
var anxReader = new BinaryReader(anx.BaseStream);
for (int index = 0; index < 4; index++)
Assert.AreEqual(xnaReader.ReadSingle(), anxReader.ReadSingle());
}
[Test]
public void WriteMatrix()
{
var xna = new XNAPacketWriter();
var anx = new ANXPacketWriter();
xna.Write(Microsoft.Xna.Framework.Matrix.CreateRotationY(0.1f));
anx.Write(Matrix.CreateRotationY(0.1f));
Assert.AreEqual(xna.Length, anx.Length);
Assert.AreEqual(xna.Position, anx.Position);
xna.Position = 0;
anx.Position = 0;
var xnaReader = new BinaryReader(xna.BaseStream);
var anxReader = new BinaryReader(anx.BaseStream);
for (int index = 0; index < 16; index++)
Assert.AreEqual(xnaReader.ReadSingle(), anxReader.ReadSingle());
}
[Test]
public void WriteQuaternion()
{
var xna = new XNAPacketWriter();
var anx = new ANXPacketWriter();
xna.Write(new Microsoft.Xna.Framework.Quaternion(0.1f, 15f, 3.4f, 4f));
anx.Write(new Quaternion(0.1f, 15f, 3.4f, 4f));
Assert.AreEqual(xna.Length, anx.Length);
Assert.AreEqual(xna.Position, anx.Position);
xna.Position = 0;
anx.Position = 0;
var xnaReader = new BinaryReader(xna.BaseStream);
var anxReader = new BinaryReader(anx.BaseStream);
for (int index = 0; index < 4; index++)
Assert.AreEqual(xnaReader.ReadSingle(), anxReader.ReadSingle());
}
[Test]
public void WriteColor()
{
var xna = new XNAPacketWriter();
var anx = new ANXPacketWriter();
xna.Write(Microsoft.Xna.Framework.Color.CornflowerBlue);
anx.Write(Color.CornflowerBlue);
Assert.AreEqual(xna.Length, anx.Length);
Assert.AreEqual(xna.Position, anx.Position);
xna.Position = 0;
anx.Position = 0;
var xnaReader = new BinaryReader(xna.BaseStream);
var anxReader = new BinaryReader(anx.BaseStream);
Assert.AreEqual(xnaReader.ReadUInt32(), anxReader.ReadUInt32());
}
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Globalization;
using System.Reflection;
using NUnit.Framework;
using XNAQualityOfService = Microsoft.Xna.Framework.Net.QualityOfService;
using ANXQualityOfService = ANX.Framework.Net.QualityOfService;
// 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.Net
{
class QualityOfServiceTest
{
[Test]
public void Constructor1()
{
var xna = (XNAQualityOfService)Activator.CreateInstance(typeof(XNAQualityOfService), true);
var anx = (ANXQualityOfService)Activator.CreateInstance(typeof(ANXQualityOfService), true);
Assert.AreEqual(xna.IsAvailable, anx.IsAvailable);
Assert.AreEqual(xna.BytesPerSecondUpstream, anx.BytesPerSecondUpstream);
Assert.AreEqual(xna.BytesPerSecondDownstream, anx.BytesPerSecondDownstream);
Assert.AreEqual(xna.AverageRoundtripTime, anx.AverageRoundtripTime);
Assert.AreEqual(xna.MinimumRoundtripTime, anx.MinimumRoundtripTime);
}
[Test]
public void Constructor2()
{
var parameters = new object[] { 1024, 512, TimeSpan.FromSeconds(10.0), TimeSpan.FromSeconds(1.0) };
var xna = (XNAQualityOfService)Activator.CreateInstance(typeof(XNAQualityOfService),
BindingFlags.NonPublic | BindingFlags.Instance, null, parameters, CultureInfo.InvariantCulture);
var anx = (ANXQualityOfService)Activator.CreateInstance(typeof(ANXQualityOfService),
BindingFlags.NonPublic | BindingFlags.Instance, null, parameters, CultureInfo.InvariantCulture);
Assert.AreEqual(xna.IsAvailable, anx.IsAvailable);
Assert.AreEqual(xna.BytesPerSecondUpstream, anx.BytesPerSecondUpstream);
Assert.AreEqual(xna.BytesPerSecondDownstream, anx.BytesPerSecondDownstream);
Assert.AreEqual(xna.AverageRoundtripTime, anx.AverageRoundtripTime);
Assert.AreEqual(xna.MinimumRoundtripTime, anx.MinimumRoundtripTime);
}
}
}

View File

@ -11,11 +11,11 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Net
{
[PercentageComplete(0)]
[PercentageComplete(95)]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class AvailableNetworkSession
{
public AvailableNetworkSession()
internal AvailableNetworkSession()
{
QualityOfService = new QualityOfService();
}

View File

@ -8,7 +8,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Net
{
[PercentageComplete(0)]
[PercentageComplete(95)]
[TestState(TestStateAttribute.TestState.Untested)]
public class NetworkException : Exception
{

View File

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

View File

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

View File

@ -8,7 +8,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Net
{
[PercentageComplete(0)]
[PercentageComplete(95)]
[TestState(TestStateAttribute.TestState.Untested)]
public class NetworkSessionJoinException : NetworkException
{

View File

@ -9,97 +9,93 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Net
{
[PercentageComplete(0)]
[TestState(TestStateAttribute.TestState.Untested)]
public class NetworkSessionProperties : IList<int?>, ICollection<int?>,
IEnumerable<int?>, IEnumerable
{
#region IList<int?> Member
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public class NetworkSessionProperties : IList<int?>, ICollection<int?>, IEnumerable<int?>, IEnumerable
{
private const int DataCount = 8;
public int IndexOf(int? item)
{
throw new NotImplementedException();
private readonly int?[] data = new int?[DataCount];
public int Count
{
get { return DataCount; }
}
bool ICollection<int?>.IsReadOnly
{
get { return false; }
}
public int? this[int index]
{
get
{
if (index < 0 || index >= DataCount)
throw new ArgumentOutOfRangeException("index");
return data[index];
}
set
{
if (index < 0 || index >= DataCount)
throw new ArgumentOutOfRangeException("index");
data[index] = value;
}
}
public int IndexOf(int? item)
{
return ((IList<int?>)data).IndexOf(item);
}
public void Insert(int index, int? item)
{
throw new NotImplementedException();
}
bool ICollection<int?>.Contains(int? item)
{
return ((IList<int?>)data).Contains(item);
}
public void RemoveAt(int index)
{
throw new NotImplementedException();
}
void ICollection<int?>.CopyTo(int?[] array, int arrayIndex)
{
data.CopyTo(array, arrayIndex);
}
public int? this[int index]
{
get
{
throw new NotImplementedException();
}
set
{
throw new NotImplementedException();
}
}
public IEnumerator<int?> GetEnumerator()
{
return ((IList<int?>)data).GetEnumerator();
}
#endregion
IEnumerator IEnumerable.GetEnumerator()
{
return data.GetEnumerator();
}
#region ICollection<int?> Member
#region Unsupported Methods
void IList<int?>.Insert(int index, int? item)
{
throw new NotSupportedException();
}
public void Add(int? item)
{
throw new NotImplementedException();
}
void ICollection<int?>.Add(int? item)
{
throw new NotSupportedException();
}
public void Clear()
{
throw new NotImplementedException();
}
void ICollection<int?>.Clear()
{
throw new NotSupportedException();
}
public bool Contains(int? item)
{
throw new NotImplementedException();
}
bool ICollection<int?>.Remove(int? item)
{
throw new NotSupportedException();
}
public void CopyTo(int?[] array, int arrayIndex)
{
throw new NotImplementedException();
}
public int Count
{
get { throw new NotImplementedException(); }
}
public bool IsReadOnly
{
get { throw new NotImplementedException(); }
}
public bool Remove(int? item)
{
throw new NotImplementedException();
}
#endregion
#region IEnumerable<int?> Member
public IEnumerator<int?> GetEnumerator()
{
throw new NotImplementedException();
}
#endregion
#region IEnumerable Member
IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
#endregion
void IList<int?>.RemoveAt(int index)
{
throw new NotSupportedException();
}
#endregion
}
}

View File

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

View File

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

View File

@ -9,7 +9,8 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Net
{
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public class PacketReader : BinaryReader
{
public int Length

View File

@ -9,7 +9,8 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Net
{
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public class PacketWriter : BinaryWriter
{
public int Length

View File

@ -8,13 +8,28 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Net
{
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Tested)]
public sealed class QualityOfService
{
public bool IsAvailable { get; internal set; }
public int BytesPerSecondUpstream { get; internal set; }
public int BytesPerSecondDownstream { get; internal set; }
public TimeSpan AverageRoundtripTime { get; internal set; }
public TimeSpan MinimumRoundtripTime { get; internal set; }
public bool IsAvailable { get; private set; }
public int BytesPerSecondUpstream { get; private set; }
public int BytesPerSecondDownstream { get; private set; }
public TimeSpan AverageRoundtripTime { get; private set; }
public TimeSpan MinimumRoundtripTime { get; private set; }
internal QualityOfService()
{
}
internal QualityOfService(int bytesPerSecondUpstream, int bytesPerSecondDownstream, TimeSpan averageRoundtripTime,
TimeSpan minimumRoundtripTime)
{
BytesPerSecondUpstream = bytesPerSecondUpstream;
BytesPerSecondDownstream = bytesPerSecondDownstream;
AverageRoundtripTime = averageRoundtripTime;
MinimumRoundtripTime = minimumRoundtripTime;
IsAvailable = true;
}
}
}

View File

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