public async Task CreateChineseFile() { string fileName = "这是我的项目"; string description = "此项目由Facepunch Steamworks单元测试创建"; var result = await Ugc.Editor.NewCommunityFile .WithTitle(fileName) .WithDescription(description) .WithTag("Arsehole") .WithTag("Spiteful") .WithTag("Fat-Head") .SubmitAsync(); Console.WriteLine($"Title: {fileName}"); Console.WriteLine($"Description: {description}"); Assert.IsTrue(result.Success); Assert.AreNotEqual(result.FileId.Value, 0); var file = await Steamworks.SteamUGC.QueryFileAsync(result.FileId); Console.WriteLine($"FileId: {result.FileId}"); Console.WriteLine($"Title: {file.Value.Title}"); Console.WriteLine($"Description: {file.Value.Description}"); Assert.AreEqual(file.Value.Title, fileName); Assert.AreEqual(file.Value.Description, description); var deleted = await SteamUGC.DeleteFileAsync(result.FileId); Assert.IsTrue(deleted); }
public async Task CreateAndThenEditFile() { PublishedFileId fileid; // // Make a file // { var result = await Ugc.Editor.NewCommunityFile .WithTitle("Unedited File") .SubmitAsync(); Assert.IsTrue(result.Success); Assert.AreNotEqual(result.FileId.Value, 0); fileid = result.FileId; } await Task.Delay(1000); // // Edit it // { var editor = new Ugc.Editor(fileid); editor = editor.WithTitle("An Edited File"); var result = await editor.SubmitAsync(); Assert.IsTrue(result.Success); Assert.AreEqual(result.FileId, fileid); } await Task.Delay(1000); // // Make sure the edited file matches // { var details = await SteamUGC.QueryFileAsync(fileid) ?? throw new Exception("Somethign went wrong"); Assert.AreEqual(details.Id, fileid); Assert.AreEqual(details.Title, "An Edited File"); } // // Clean up // var deleted = await SteamUGC.DeleteFileAsync(fileid); Assert.IsTrue(deleted); }
public async Task CreateFile() { var result = await Ugc.Editor.NewCommunityFile .WithTitle("Unit Test Created Item") .WithDescription("This item was created by Facepunch Steamworks unit tests.\n\n" + "It should have technically been deleted so you should never get to " + "read this unless something terrible has happened.") .SubmitAsync(); Assert.IsTrue(result.Success); Assert.AreNotEqual(result.FileId.Value, 0); var deleted = await SteamUGC.DeleteFileAsync(result.FileId); Assert.IsTrue(deleted); }
public async Task UploadBigishFile() { var created = Ugc.Editor.NewCommunityFile .WithTitle("Unit Test Upload Item") .WithDescription("This item was created by Facepunch Steamworks unit tests.\n\n" + "It should have technically been deleted so you should never get to " + "read this unless something terrible has happened.") //.WithTag( "Apple" ) //.WithTag( "Banana" ) ; // Make a folder var testFolder = new System.IO.DirectoryInfo("WorkshopUpload"); if (!testFolder.Exists) { testFolder.Create(); } created = created.WithContent(testFolder.FullName); // Upload a file of random bytes var rand = new Random(); var testFile = new byte[1024 * 1024 * 32]; rand.NextBytes(testFile); System.IO.File.WriteAllBytes(testFolder.FullName + "/testfile1.bin", testFile); Console.WriteLine(testFolder.FullName); try { var done = await created.SubmitAsync(new ProgressBar()); Assert.IsTrue(done.Success); Console.WriteLine("item.Id: {0}", done.FileId); var deleted = await SteamUGC.DeleteFileAsync(done.FileId); Assert.IsTrue(deleted); } finally { System.IO.File.Delete(testFolder.FullName + "/testfile.bin"); } }