mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 22:58:01 +03:00
Added tests for new inventory stuff
This commit is contained in:
parent
796fd29e32
commit
2ecf323ae0
@ -18,14 +18,14 @@ namespace Facepunch.Steamworks.Test
|
|||||||
Assert.IsNotNull( client.Inventory.Definitions );
|
Assert.IsNotNull( client.Inventory.Definitions );
|
||||||
Assert.AreNotEqual( 0, client.Inventory.Definitions.Length );
|
Assert.AreNotEqual( 0, client.Inventory.Definitions.Length );
|
||||||
|
|
||||||
foreach ( var i in client.Inventory.Definitions.Where( x => x.PriceRaw != "" ) )
|
foreach ( var i in client.Inventory.Definitions.Where( x => x.PriceCategory != "" ) )
|
||||||
{
|
{
|
||||||
Console.WriteLine( "{0}: {1} ({2})", i.Id, i.Name, i.Type );
|
Console.WriteLine( "{0}: {1} ({2})", i.Id, i.Name, i.Type );
|
||||||
Console.WriteLine( " itemshortname: {0}", i.GetStringProperty( "itemshortname" ) );
|
Console.WriteLine( " itemshortname: {0}", i.GetStringProperty( "itemshortname" ) );
|
||||||
Console.WriteLine( " workshopdownload: {0}", i.GetStringProperty( "workshopdownload" ) );
|
Console.WriteLine( " workshopdownload: {0}", i.GetStringProperty( "workshopdownload" ) );
|
||||||
Console.WriteLine( " IconUrl: {0}", i.IconUrl );
|
Console.WriteLine( " IconUrl: {0}", i.IconUrl );
|
||||||
Console.WriteLine( " IconLargeUrl: {0}", i.IconLargeUrl );
|
Console.WriteLine( " IconLargeUrl: {0}", i.IconLargeUrl );
|
||||||
Console.WriteLine( " PriceRaw: {0}", i.PriceRaw );
|
Console.WriteLine( " PriceRaw: {0}", i.PriceCategory );
|
||||||
Console.WriteLine( " PriceDollars: {0}", i.PriceDollars );
|
Console.WriteLine( " PriceDollars: {0}", i.PriceDollars );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,6 +119,8 @@ namespace Facepunch.Steamworks.Test
|
|||||||
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
using ( var client = new Facepunch.Steamworks.Client( 252490 ) )
|
||||||
{
|
{
|
||||||
Assert.IsTrue( client.IsValid );
|
Assert.IsTrue( client.IsValid );
|
||||||
|
Assert.IsNotNull(client.Inventory.Definitions);
|
||||||
|
Assert.AreNotEqual(0, client.Inventory.Definitions.Length);
|
||||||
|
|
||||||
client.Inventory.Refresh();
|
client.Inventory.Refresh();
|
||||||
|
|
||||||
@ -166,5 +168,58 @@ namespace Facepunch.Steamworks.Test
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void PurchaseItems()
|
||||||
|
{
|
||||||
|
using (var client = new Facepunch.Steamworks.Client(252490))
|
||||||
|
{
|
||||||
|
Assert.IsNotNull(client.Inventory.Definitions);
|
||||||
|
Assert.AreNotEqual(0, client.Inventory.Definitions.Length);
|
||||||
|
|
||||||
|
while ( client.Inventory.Currency == null )
|
||||||
|
{
|
||||||
|
client.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
var shoppingList = client.Inventory.DefinitionsWithPrices.Take(2).ToArray();
|
||||||
|
bool waitingForCallback = true;
|
||||||
|
|
||||||
|
if ( !client.Inventory.StartPurchase(shoppingList, ( order, tran ) =>
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Order: {order}, Transaction {tran}");
|
||||||
|
waitingForCallback = false;
|
||||||
|
|
||||||
|
} ) )
|
||||||
|
{
|
||||||
|
throw new Exception("Couldn't Buy!");
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( waitingForCallback )
|
||||||
|
{
|
||||||
|
client.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void ListPrices()
|
||||||
|
{
|
||||||
|
using (var client = new Facepunch.Steamworks.Client(252490))
|
||||||
|
{
|
||||||
|
Assert.IsNotNull(client.Inventory.Definitions);
|
||||||
|
Assert.AreNotEqual(0, client.Inventory.Definitions.Length);
|
||||||
|
|
||||||
|
while (client.Inventory.Currency == null)
|
||||||
|
{
|
||||||
|
client.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( var i in client.Inventory.Definitions.Where( x => x.LocalPrice > 0 ) )
|
||||||
|
{
|
||||||
|
Console.WriteLine( $" {i.Name} - {i.LocalPriceFormatted} ({client.Inventory.Currency})" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user