2016-10-04 18:47:48 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Facepunch.Steamworks.Test
|
|
|
|
|
{
|
|
|
|
|
public partial class Server
|
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
2016-10-05 11:44:35 +03:00
|
|
|
|
public void InventoryDeserialize()
|
2016-10-04 18:47:48 +03:00
|
|
|
|
{
|
|
|
|
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
2016-10-05 14:44:01 +03:00
|
|
|
|
Assert.IsTrue( client.IsValid );
|
2016-10-04 18:47:48 +03:00
|
|
|
|
|
|
|
|
|
Assert.IsNull( client.Inventory.SerializedItems );
|
|
|
|
|
|
|
|
|
|
client.Inventory.Refresh();
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Block until we have the items
|
|
|
|
|
//
|
|
|
|
|
while ( client.Inventory.SerializedItems == null )
|
|
|
|
|
{
|
|
|
|
|
client.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull( client.Inventory.SerializedItems );
|
|
|
|
|
Assert.IsTrue( client.Inventory.SerializedItems.Length > 4 );
|
|
|
|
|
|
|
|
|
|
using ( var server = new Facepunch.Steamworks.Server( 252490, 0, 30002, true, "VersionString" ) )
|
|
|
|
|
{
|
|
|
|
|
server.LogOnAnonymous();
|
2016-10-05 14:44:01 +03:00
|
|
|
|
Assert.IsTrue( server.IsValid );
|
2016-10-04 18:47:48 +03:00
|
|
|
|
|
|
|
|
|
var result = server.Inventory.Deserialize( client.Inventory.SerializedItems );
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue( result.Block() );
|
|
|
|
|
Assert.IsNotNull( result.Items );
|
|
|
|
|
|
|
|
|
|
foreach ( var item in result.Items )
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine( "Item: {0} ({1})", item.Id, item.DefinitionId );
|
|
|
|
|
Console.WriteLine( "Item: {0} ({1})", item.Id, item.DefinitionId );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|