Search the source of every open source package.
56 results
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using Braxnet;
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
// var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
Assert.IsTrue( scene.Directory.FindByName( "LibraryTestComponent" ) != null );
}
}
}
[Autoload]
public class LibraryTestComponent : Component
{
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Sandbox;
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using System.Text.Json.Serialization;
using Mongo.Rest;
using Sandbox;
[MongoCollection( "users" )]
public record User
{
[JsonPropertyName( "_id" )] public string Id { get; set; } = null!;
public string Name { get; set; } = null!;
public int Age { get; set; }
}
public sealed class UserRepository : MongoRepository<User>
{
public UserRepository( Scene scene ) : base( scene ) { }
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
/*
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
*/
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using Sandbox;
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Editor;
using Editor.Inspectors;
using Editor.MapEditor;
using Sandbox;
using Sandbox.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
[EditorTool] // this class is an editor tool
[Title( "Object placement tool" )] // title of your tool
[Icon( "add_circle" )]
[Description( "Shortcut : Shift+E" )]
[Group( "0" )]
[Shortcut( "editortool.placeobj", "Shift+E" )] // keyboard shortcut
public class PlaceObj : EditorTool
{
IntProperty deltaFloat;
Vector3 placePos;
Vector3 placeOffsetPos;
Rotation normalRot;
public GameObject prefabTemplate;
public float placeDeltaDistance;
public bool useSurfaceNormal;
public bool showOnlyCustom;
public Checkbox surfSwitch;
public Checkbox customSwitch;
PrefabFile prefabItem;
WidgetWindow window;
Label currentPrefabText;
public override void OnEnabled()
{
AllowGameObjectSelection = false;
Selection.Clear();
// create a widget window. This is a window that
// can be dragged around in the scene view
window = new WidgetWindow( SceneOverlay );
window.Layout = Layout.Column();
window.WindowTitle = "Select object";
window.Layout.Margin = 4;
window.AcceptDrops = false;
window.FixedWidth = 210f;
window.Icon = "add_circle";
window.IsDraggable = false;
surfSwitch = new Checkbox( "Align to surface", window );
window.Layout.Add( surfSwitch );
window.Layout.AddSpacingCell( 8 );
customSwitch = new Checkbox( "Show only custom prefabs", window );
window.Layout.Add( customSwitch );
window.Layout.AddSpacingCell( 8 );
//Create float for surface distance offset
deltaFloat = window.Layout.Add( new IntProperty( window ) { HighlightColor = Theme.Yellow, Icon = "height", ToolTip = "Distance from surface", Value = 8 } );
window.Layout.AddSpacingCell( 8 );
var button = new Button( "Open all" );
button.Pressed = () => OpenAllFunctions(button.ScreenPosition);
currentPrefabText = new Label() { Text = "none" };
window.Layout.Add( currentPrefabText );
// Add the button to the window's layout
window.Layout.Add( button );
// Calling this function means that when your tool is deleted,
// ui will get properly deleted too. If you don't call this and
// you don't delete your UI in OnDisabled, it'll hang around forever.
AddOverlay( window, TextFlag.LeftTop, 10 );
}
//adds an empty gameobject at location, should replace it with library later
void AddObject(PrefabFile entry)
{
if ( entry != null )
{
using var scope = SceneEditorSession.Scope();
var go = SceneUtility.GetPrefabScene( entry )?.Clone();
go.BreakFromPrefab();
go.Name = entry.MenuPath.Split( '/' ).Last();
go.Transform.Local = new Transform( placeOffsetPos, normalRot );
Selection.Set( go );
}
}
void OpenAllFunctions(Vector2 pos)
{
showOnlyCustom = customSwitch.Value;
var menu = new Menu();
if ( customSwitch.Value == false )
{
var prefabs = AssetSystem.All.Where( x => x.AssetType.FileExtension == "prefab" )
.Where( x => x.RelativePath.StartsWith( "templates/gameobject/" ) )
.Select( x => x.LoadResource<PrefabFile>() )
.Where( x => x.ShowInMenu )
.OrderByDescending( x => x.MenuPath.Count( x => x == '/' ) )
.ThenBy( x => x.MenuPath )
.ToArray();
foreach ( var entry in prefabs )
{
menu.AddOption( entry.MenuPath.Split( '/' ), entry.MenuIcon, () =>
{
using var scope = SceneEditorSession.Scope();
prefabItem = entry;
currentPrefabText.Text = entry.ToString();
} );
}
}
var CustomPrefabs = AssetSystem.All.Where( x => x.AssetType.FileExtension == "prefab" )
.Where( x => x.RelativePath.StartsWith( "prefabs/templates" ) )
.Select( x => x.LoadResource<PrefabFile>() )
.Where( x => x.ShowInMenu )
.OrderByDescending( x => x.MenuPath.Count( x => x == '/' ) )
.ThenBy( x => x.MenuPath )
.ToArray();
foreach ( var entry in CustomPrefabs )
{
menu.AddOption( entry.MenuPath.Split( '/' ), entry.MenuIcon, () =>
{
using var scope = SceneEditorSession.Scope();
prefabItem = entry;
currentPrefabText.Text = entry.ToString();
} );
}
menu.OpenAt( pos, false );
}
public override void OnUpdate()
{
placeDeltaDistance = deltaFloat.Value;
useSurfaceNormal = surfSwitch.Value;
var tr = Scene.Trace.Ray( Gizmo.CurrentRay, 5000 )
.UseRenderMeshes( true )
.UsePhysicsWorld( false )
.Run();
if ( tr.Hit )
{
using ( Gizmo.Scope( "cursor" ) )
{
placePos = tr.HitPosition;
placePos = placePos.SnapToGrid( EditorScene.GizmoInstance.Settings.GridSpacing, true, true, true );
Gizmo.Transform = new Transform( placePos, Rotation.LookAt( tr.Normal ) );
Gizmo.Draw.Color = Gizmo.Colors.Blue;
Gizmo.Draw.LineCircle( 0, 4f );
Gizmo.Draw.Color = Gizmo.Colors.Green;
placeOffsetPos = placePos + tr.Normal * placeDeltaDistance;
if ( useSurfaceNormal )
{
normalRot = Rotation.LookAt( tr.Normal );
}
else
{
normalRot = Angles.Zero;
}
Gizmo.Transform = new Transform( placeOffsetPos, Rotation.LookAt( tr.Normal ) );
Gizmo.Draw.LineBBox( BBox.FromPositionAndSize( 0, 4f ) );
if ( Gizmo.HasClicked ) AddObject(prefabItem);
}
}
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using System;
using System.Linq;
using System.Threading.Tasks;
using Mongo.Rest;
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestInitialize]
public void Initialize()
{
var scene = new Scene();
Configure( scene );
}
[TestCleanup]
public void Cleanup()
{
var scene = new Scene();
Configure( scene );
DeleteAllRecords( scene ).GetAwaiter().GetResult();
}
[TestMethod]
public void CreateUserTest()
{
var scene = new Scene();
Configure( scene );
CreateUser( scene ).GetAwaiter().GetResult();
}
[TestMethod]
public void CreateMultipleUsersTest()
{
var scene = new Scene();
Configure( scene );
CreateMultipleUsers( scene ).GetAwaiter().GetResult();
}
[TestMethod]
public void DeleteUserTest()
{
var scene = new Scene();
Configure( scene );
var user = CreateUser( scene ).GetAwaiter().GetResult();
DeleteUser( scene, user ).GetAwaiter().GetResult();
}
[TestMethod]
public void UpdateUserTest()
{
var scene = new Scene();
Configure( scene );
var user = CreateUser( scene ).GetAwaiter().GetResult();
UpdateUser( scene, user ).GetAwaiter().GetResult();
}
[TestMethod]
public void GetUserTest()
{
var scene = new Scene();
Configure( scene );
var user = CreateUser( scene ).GetAwaiter().GetResult();
GetUser( scene, user ).GetAwaiter().GetResult();
}
[TestMethod]
public void CountUsersTest()
{
var scene = new Scene();
Configure( scene );
CreateMultipleUsers( scene ).GetAwaiter().GetResult();
CountAllUsers( scene, 3 ).GetAwaiter().GetResult();
}
[TestMethod]
public void CountUserTest()
{
var scene = new Scene();
Configure( scene );
CreateUser( scene ).GetAwaiter().GetResult();
CountUser( scene, 1 ).GetAwaiter().GetResult();
}
[TestMethod]
public void GetUsersTest()
{
var scene = new Scene();
Configure( scene );
CreateMultipleUsers( scene ).GetAwaiter().GetResult();
GetAllUsers( scene ).GetAwaiter().GetResult();
}
[TestMethod]
public void ExistsUserTest()
{
var scene = new Scene();
Configure( scene );
var user = CreateUser( scene ).GetAwaiter().GetResult();
ExistsUser( scene, user ).GetAwaiter().GetResult();
}
private static async Task<User> CreateUser( Scene scene )
{
var users = new UserRepository( scene );
var user = new User { Identifier = Guid.NewGuid().ToString(), Name = "John Doe", Age = Random.Shared.Next( 1, 100 ) };
var inserted = await users.InsertAsync( user );
Assert.AreEqual( inserted, true );
return user;
}
private static async Task CreateMultipleUsers( Scene scene )
{
var users = new UserRepository( scene );
var user1 = new User { Identifier = Guid.NewGuid().ToString(), Name = "John Doe", Age = Random.Shared.Next( 1, 100 ) };
var user2 = new User
{
Identifier = Guid.NewGuid().ToString(), Name = "Marry Jane", Age = Random.Shared.Next( 1, 100 )
};
var user3 = new User { Identifier = Guid.NewGuid().ToString(), Name = "Lola Doe", Age = Random.Shared.Next( 1, 100 ) };
var inserted = await users.InsertAsync( user1, user2, user3 );
Assert.AreEqual( inserted, true );
}
private static async Task DeleteAllRecords( Scene scene )
{
var users = new UserRepository( scene );
await users.DeleteAsync();
}
private static async Task DeleteUser( Scene scene, User user )
{
var users = new UserRepository( scene );
var deleted = await users.DeleteAsync( x => x.Name = user.Name );
Assert.AreEqual( deleted, true );
}
private static async Task UpdateUser( Scene scene, User user )
{
var users = new UserRepository( scene );
var updated = await users.UpdateAsync( x => x.Name = user.Name, x => x.Age = Random.Shared.Next( 1, 100 ) );
Assert.AreEqual( updated, true );
}
private static async Task GetUser( Scene scene, User user )
{
var repo = new UserRepository( scene );
var users = (await repo.GetAsync( x => x.Name = user.Name )).ToList();
Assert.AreEqual( users.Count, 1 );
var other = users.FirstOrDefault();
Assert.IsNotNull( other );
}
private static async Task GetAllUsers( Scene scene )
{
var users = new UserRepository( scene );
var usersList = await users.GetAsync( limit: 3 );
Assert.AreEqual( usersList.Count(), 3 );
}
private static async Task ExistsUser( Scene scene, User user )
{
var users = new UserRepository( scene );
var exists = await users.ExistsAsync( x => x.Name = user.Name );
Assert.AreEqual( exists, true );
}
private static async Task CountAllUsers( Scene scene, int count )
{
var users = new UserRepository( scene );
var total = await users.CountAsync();
Assert.AreEqual( total, count );
}
private static async Task CountUser( Scene scene, int count )
{
var users = new UserRepository( scene );
var total = await users.CountAsync( x => x.Name = "John Doe" );
Assert.AreEqual( total, count );
}
private static void Configure( Scene scene )
{
var system = scene.GetSystem<MongoRestSystem>();
system.Initialize();
system.Configure( options =>
{
options.Url = "https://localhost:443";
options.Database = "Orizon";
} );
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using Sandbox;
/*
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
*/
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Reflection;
using Sandbox.Internal;
namespace Sandbox.Events.Tests;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Application.InitUnitTest();
var addAssemblyMethod = typeof(TypeLibrary)
.GetMethod( "AddAssembly", BindingFlags.NonPublic | BindingFlags.Instance, new[] { typeof(Assembly), typeof(bool) } )!;
addAssemblyMethod.Invoke( GlobalGameNamespace.TypeLibrary, new object?[] { Assembly.GetExecutingAssembly(), true } );
}
}
namespace Sandbox.Events.Tests;
[TestClass]
public class DispatchTests
{
[TestMethod]
public void Simple()
{
var scene = new Scene();
using var _ = scene.Push();
var go = new GameObject();
go.Components.Create<EarlyHandler>();
go.Components.Create<Handler>();
go.Components.Create<LateHandler>();
go.Components.Create<AfterLateHandler>();
go.Components.Create<BeforeLateHandler>();
go.Components.Create<AfterEarlyHandler>();
go.Components.Create<BeforeEarlyHandler>();
go.Components.Create<BeforeHandler>();
go.Components.Create<AfterHandler>();
scene.Dispatch( new ExampleEventArgs() );
Assert.IsTrue( go.Components.Get<EarlyHandler>().Index < go.Components.Get<Handler>().Index );
Assert.IsTrue( go.Components.Get<Handler>().Index < go.Components.Get<LateHandler>().Index );
Assert.IsTrue( go.Components.Get<BeforeEarlyHandler>().Index < go.Components.Get<EarlyHandler>().Index );
Assert.IsTrue( go.Components.Get<EarlyHandler>().Index < go.Components.Get<AfterEarlyHandler>().Index );
Assert.IsTrue( go.Components.Get<BeforeHandler>().Index < go.Components.Get<Handler>().Index );
Assert.IsTrue( go.Components.Get<Handler>().Index < go.Components.Get<AfterHandler>().Index );
Assert.IsTrue( go.Components.Get<BeforeLateHandler>().Index < go.Components.Get<LateHandler>().Index );
Assert.IsTrue( go.Components.Get<LateHandler>().Index < go.Components.Get<AfterLateHandler>().Index );
}
}
public class ExampleEventArgs : IGameEvent
{
public int HandleCount { get; set; }
}
public abstract class BaseHandler : Component
{
public int Index { get; set; }
protected void Handle( ExampleEventArgs eventArgs )
{
Index = ++eventArgs.HandleCount;
}
}
public sealed class Handler : BaseHandler, IGameEventHandler<ExampleEventArgs>
{
void IGameEventHandler<ExampleEventArgs>.OnGameEvent( ExampleEventArgs eventArgs ) => Handle( eventArgs );
}
public sealed class EarlyHandler : BaseHandler, IGameEventHandler<ExampleEventArgs>
{
[Early]
void IGameEventHandler<ExampleEventArgs>.OnGameEvent( ExampleEventArgs eventArgs ) => Handle( eventArgs );
}
public sealed class LateHandler : BaseHandler, IGameEventHandler<ExampleEventArgs>
{
[Late]
void IGameEventHandler<ExampleEventArgs>.OnGameEvent( ExampleEventArgs eventArgs ) => Handle( eventArgs );
}
public sealed class BeforeHandler : BaseHandler, IGameEventHandler<ExampleEventArgs>
{
[Before<Handler>]
void IGameEventHandler<ExampleEventArgs>.OnGameEvent( ExampleEventArgs eventArgs ) => Handle( eventArgs );
}
public sealed class AfterHandler : BaseHandler, IGameEventHandler<ExampleEventArgs>
{
[After<Handler>]
void IGameEventHandler<ExampleEventArgs>.OnGameEvent( ExampleEventArgs eventArgs ) => Handle( eventArgs );
}
public sealed class BeforeEarlyHandler : BaseHandler, IGameEventHandler<ExampleEventArgs>
{
[Before<EarlyHandler>]
void IGameEventHandler<ExampleEventArgs>.OnGameEvent( ExampleEventArgs eventArgs ) => Handle( eventArgs );
}
public sealed class AfterEarlyHandler : BaseHandler, IGameEventHandler<ExampleEventArgs>
{
[After<EarlyHandler>]
void IGameEventHandler<ExampleEventArgs>.OnGameEvent( ExampleEventArgs eventArgs ) => Handle( eventArgs );
}
public sealed class BeforeLateHandler : BaseHandler, IGameEventHandler<ExampleEventArgs>
{
[Before<LateHandler>]
void IGameEventHandler<ExampleEventArgs>.OnGameEvent( ExampleEventArgs eventArgs ) => Handle( eventArgs );
}
public sealed class AfterLateHandler : BaseHandler, IGameEventHandler<ExampleEventArgs>
{
[After<LateHandler>]
void IGameEventHandler<ExampleEventArgs>.OnGameEvent( ExampleEventArgs eventArgs ) => Handle( eventArgs );
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}
using Sandbox;
[TestClass]
public partial class LibraryTests
{
[TestMethod]
public void SceneTest()
{
var scene = new Scene();
using ( scene.Push() )
{
var go = new GameObject();
Assert.AreEqual( 1, scene.Directory.GameObjectCount );
}
}
}
global using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestInit
{
[AssemblyInitialize]
public static void ClassInitialize( TestContext context )
{
Sandbox.Application.InitUnitTest();
}
}