public void IsInPlayerLoop_WorldNotInPlayerLoop_ReturnsFalse() { using (var world = new World("Test World")) { world.CreateSystem <InitializationSystemGroup>(); var playerLoop = PlayerLoop.GetDefaultPlayerLoop(); Assert.IsFalse(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(world, playerLoop)); } }
public void RemoveFromPlayerLoop_WorldNotInPlayerLoop_DoesntThrow() { using (var world = new World("Test World")) { world.CreateSystem <InitializationSystemGroup>(); var playerLoop = PlayerLoop.GetDefaultPlayerLoop(); ScriptBehaviourUpdateOrder.RemoveWorldFromPlayerLoop(world, ref playerLoop); Assert.IsFalse(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(world, playerLoop)); } }
public void AddToPlayerLoop_AddTwoWorlds_BothAreAdded() { using (var worldA = new World("Test World A")) using (var worldB = new World("Test World B")) { worldA.CreateSystem <InitializationSystemGroup>(); worldB.CreateSystem <InitializationSystemGroup>(); var playerLoop = PlayerLoop.GetDefaultPlayerLoop(); ScriptBehaviourUpdateOrder.AddWorldToPlayerLoop(worldA, ref playerLoop); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(worldA, playerLoop)); ScriptBehaviourUpdateOrder.AddWorldToPlayerLoop(worldB, ref playerLoop); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(worldA, playerLoop)); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(worldB, playerLoop)); } }
public void AddRemoveScriptUpdate() { DefaultWorldInitialization.Initialize("Test World", true); var newWorld = new World("WorldA"); Assert.IsFalse(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(newWorld)); ScriptBehaviourUpdateOrder.UpdatePlayerLoop(newWorld); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(newWorld)); ScriptBehaviourUpdateOrder.UpdatePlayerLoop(null); Assert.IsFalse(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(newWorld)); ScriptBehaviourUpdateOrder.UpdatePlayerLoop(World.DefaultGameObjectInjectionWorld); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(World.DefaultGameObjectInjectionWorld)); }
public void RemoveFromPlayerLoop_OtherWorldsInPlayerLoop_NotAffected() { using (var worldA = new World("Test World A")) using (var worldB = new World("Test World B")) { worldA.CreateSystem <InitializationSystemGroup>(); worldB.CreateSystem <InitializationSystemGroup>(); var playerLoop = PlayerLoop.GetDefaultPlayerLoop(); ScriptBehaviourUpdateOrder.AddWorldToPlayerLoop(worldA, ref playerLoop); ScriptBehaviourUpdateOrder.AddWorldToPlayerLoop(worldB, ref playerLoop); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(worldA, playerLoop)); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(worldB, playerLoop)); ScriptBehaviourUpdateOrder.RemoveWorldFromPlayerLoop(worldA, ref playerLoop); Assert.IsFalse(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(worldA, playerLoop)); Assert.IsTrue(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(worldB, playerLoop)); } }
public void RegisterNewWorld() { var builder = new ContainerBuilder(); builder.RegisterNewWorld("My World 1", Lifetime.Scoped); builder.RegisterNewWorld("My World 2", Lifetime.Scoped); var container = builder.Build(); var worlds = container.Resolve <IReadOnlyList <World> >(); Assert.That(worlds[0].Name, Is.EqualTo("My World 1")); Assert.That(worlds[1].Name, Is.EqualTo("My World 2")); Assert.That(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(worlds[0]), Is.True); Assert.That(ScriptBehaviourUpdateOrder.IsWorldInPlayerLoop(worlds[1]), Is.True); container.Dispose(); Assert.That(worlds[0].IsCreated, Is.False); Assert.That(worlds[1].IsCreated, Is.False); }