2017-05-15 19:11:17 +03:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
|
|
|
|
namespace Facepunch.Steamworks.Test
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
[DeploymentItem( "steam_api64.dll" )]
|
|
|
|
|
public class RemoteStorage
|
|
|
|
|
{
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void GetQuota()
|
|
|
|
|
{
|
|
|
|
|
using ( var client = new Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
2017-06-09 13:36:53 +03:00
|
|
|
|
ulong total = client.RemoteStorage.QuotaTotal;
|
|
|
|
|
var available = client.RemoteStorage.QuotaRemaining;
|
2017-05-15 19:11:17 +03:00
|
|
|
|
|
|
|
|
|
Console.WriteLine( $"Total quota: {total} bytes" );
|
|
|
|
|
Console.WriteLine( $"Available: {available} bytes" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void WriteFile()
|
|
|
|
|
{
|
|
|
|
|
using ( var client = new Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
|
|
|
|
var file = client.RemoteStorage.CreateFile( "test.txt" );
|
|
|
|
|
|
|
|
|
|
const string text = "Hello world!";
|
|
|
|
|
|
|
|
|
|
file.WriteAllText( text );
|
|
|
|
|
|
|
|
|
|
Assert.IsTrue( file.Exists );
|
|
|
|
|
|
|
|
|
|
var read = file.ReadAllText();
|
|
|
|
|
Assert.AreEqual( text, read );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-09 13:46:44 +03:00
|
|
|
|
[TestMethod]
|
|
|
|
|
public void ReadText()
|
|
|
|
|
{
|
|
|
|
|
using ( var client = new Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
|
|
|
|
var text = client.RemoteStorage.ReadString( "test.txt" );
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull( text );
|
|
|
|
|
Assert.AreEqual( text, "Hello world!" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void WriteText()
|
|
|
|
|
{
|
|
|
|
|
using ( var client = new Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
|
|
|
|
var result = client.RemoteStorage.WriteString( "test.txt", "Hello world!" );
|
|
|
|
|
Assert.IsTrue( result );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 19:11:17 +03:00
|
|
|
|
[TestMethod]
|
|
|
|
|
public void WriteFiles()
|
|
|
|
|
{
|
|
|
|
|
using ( var client = new Steamworks.Client( 252490 ) )
|
|
|
|
|
{
|
|
|
|
|
for ( var i = 0; i < 10; ++i )
|
|
|
|
|
{
|
|
|
|
|
client.RemoteStorage
|
|
|
|
|
.CreateFile( $"test_{i}/example.txt" )
|
|
|
|
|
.WriteAllText( Guid.NewGuid().ToString() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine( $"File count: {client.RemoteStorage.FileCount}" );
|
|
|
|
|
|
|
|
|
|
foreach ( var file in client.RemoteStorage.Files )
|
|
|
|
|
{
|
2017-12-23 07:48:44 +03:00
|
|
|
|
DateTime t = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(file.FileTimestamp);
|
|
|
|
|
Console.WriteLine( $"- {file.FileName} ({file.SizeInBytes} bytes), modified {t:O}" );
|
2017-05-15 19:11:17 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|