mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-02 19:38:24 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
107 lines
2.4 KiB
C#
107 lines
2.4 KiB
C#
using Sandbox.Diagnostics;
|
|
using System;
|
|
|
|
namespace Projects;
|
|
|
|
[TestClass]
|
|
public class ProjectTests
|
|
{
|
|
[TestInitialize]
|
|
public void TestInitialize()
|
|
{
|
|
Logging.Enabled = true;
|
|
Project.Clear();
|
|
AssetDownloadCache.Initialize( $"{Environment.CurrentDirectory}/.source2/project_download_folder" );
|
|
}
|
|
|
|
[TestCleanup]
|
|
public void TestCleanup()
|
|
{
|
|
Project.Clear();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Find and load a local package
|
|
/// </summary>
|
|
[TestMethod]
|
|
public void AddProject()
|
|
{
|
|
var project = Project.AddFromFile( "unittest/addons/testmap/.sbproj" );
|
|
|
|
Assert.IsNotNull( project.ConfigFilePath );
|
|
Assert.IsNotNull( project.GetRootPath() );
|
|
Assert.IsNotNull( project.GetAssetsPath() );
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Find and load a local package
|
|
/// </summary>
|
|
[TestMethod]
|
|
public async Task AddBaseAddon()
|
|
{
|
|
var project = Project.AddFromFileBuiltIn( "addons/base/.sbproj" );
|
|
|
|
Assert.IsNotNull( project.ConfigFilePath );
|
|
Assert.IsNotNull( project.GetRootPath() );
|
|
Assert.IsNotNull( project.GetAssetsPath() );
|
|
|
|
await Project.SyncWithPackageManager();
|
|
await Project.CompileAsync();
|
|
}
|
|
|
|
/*
|
|
[TestMethod]
|
|
public async Task OpenGameProject()
|
|
{
|
|
Project.AddFromFileBuiltIn( "addons/base/.sbproj" );
|
|
|
|
var project = Project.AddFromFile( "unittest/addons/spacewars", false );
|
|
|
|
var ct = new CancellationToken();
|
|
await EditorUtility.Projects.OpenProject( project.Path, null, ct ); ;
|
|
|
|
Assert.IsNotNull( project.Path );
|
|
Assert.IsNotNull( project.GetRootPath() );
|
|
Assert.IsNotNull( project.GetAssetsPath() );
|
|
|
|
var assemblies = PackageManager.MountedFileSystem.FindFile( "/.bin/", "*.dll" ).ToArray();
|
|
|
|
Assert.AreEqual( 2, assemblies.Length );
|
|
|
|
foreach ( var asm in assemblies )
|
|
{
|
|
Console.WriteLine( asm );
|
|
}
|
|
}
|
|
*/
|
|
|
|
/// <summary>
|
|
/// Initialize the menu addon
|
|
/// </summary>
|
|
[TestMethod]
|
|
public async Task MenuInitialization()
|
|
{
|
|
Project.AddFromFileBuiltIn( "addons/base/.sbproj" );
|
|
|
|
var project = Project.AddFromFile( "addons/menu/.sbproj" );
|
|
|
|
Assert.IsNotNull( project.ConfigFilePath );
|
|
Assert.IsNotNull( project.GetRootPath() );
|
|
Assert.IsNotNull( project.GetAssetsPath() );
|
|
|
|
await Project.SyncWithPackageManager();
|
|
await Project.CompileAsync();
|
|
|
|
var assemblies = PackageManager.MountedFileSystem.FindFile( "/.bin/", "*.dll", false ).ToArray();
|
|
|
|
Assert.AreEqual( 2, assemblies.Length );
|
|
|
|
foreach ( var asm in assemblies )
|
|
{
|
|
Console.WriteLine( asm );
|
|
}
|
|
|
|
}
|
|
}
|