SteamNetworkingTest

This commit is contained in:
Garry Newman 2019-04-30 22:51:01 +01:00
parent 5938bf59d4
commit 51ab76893a
2 changed files with 38 additions and 0 deletions

View File

@ -92,6 +92,7 @@
<Compile Include="FriendsTest.cs" />
<Compile Include="RemoteStorageTest.cs" />
<Compile Include="InventoryTest.cs" />
<Compile Include="SteamNetworkingTest.cs" />
<Compile Include="UgcTest.cs" />
<Compile Include="UgcEditor.cs" />
<Compile Include="UserTest.cs" />

View File

@ -0,0 +1,37 @@
using System;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Steamworks.Data;
namespace Steamworks
{
[TestClass]
[DeploymentItem( "steam_api64.dll" )]
public class SteamNetworkingTest
{
[TestMethod]
public async Task SendP2PPacket()
{
var sent = SteamNetworking.SendP2PPacket( SteamClient.SteamId, new byte[] { 1, 2, 3 } );
Assert.IsTrue( sent );
while ( !SteamNetworking.IsP2PPacketAvailable() )
{
await Task.Delay( 10 );
}
var packet = SteamNetworking.ReadP2PPacket();
Assert.IsTrue( packet.HasValue );
Assert.AreEqual( packet.Value.SteamId, SteamClient.SteamId );
Assert.AreEqual( packet.Value.Data[1], 2 );
Assert.AreEqual( packet.Value.Data.Length, 3 );
}
}
}