Beispiel #1
0
        public IEnumerable ShouldResetAppropriateObjects()
        {
            // The resetting tests must be in one test cases, otherwise problems with race
            // conditions arise (while testing).
            var probeNone = CreateObjectProbe(ResetType.None);
            var probeActiveSceneChange = CreateObjectProbe(ResetType.ActiveSceneChange);
            var probeSceneSceneLoaded  = CreateObjectProbe(ResetType.SceneLoaded);
            var probeSceneUnloaded     = CreateObjectProbe(ResetType.SceneUnloaded);

            var handler = new MutableObjectHandler(new List <IMutableObject>
            {
                probeNone,
                probeActiveSceneChange,
                probeSceneSceneLoaded,
                probeSceneUnloaded
            });

            RegisterSceneListeners(handler);

            yield return(ReloadScene());

            Assert.AreEqual(0, probeNone.ResetCount);
            Assert.AreEqual(1, probeActiveSceneChange.ResetCount);
            Assert.AreEqual(1, probeSceneSceneLoaded.ResetCount);
            Assert.AreEqual(1, probeSceneUnloaded.ResetCount);
        }
        private static void RuntimeInit()
        {
            var handler = new MutableObjectHandler(FindMutableObjects());

            handler.SetInitialMutableObjectValues();

            SceneManager.activeSceneChanged += (curr, next) => handler.ResetActiveSceneChange();
            SceneManager.sceneUnloaded      += scene => handler.ResetSceneUnloaded();
            SceneManager.sceneLoaded        += (scene, mode) => handler.ResetSceneLoaded();
        }
Beispiel #3
0
        public void ShouldSetInitialValues()
        {
            var objectProbe = CreateObjectProbe(ResetType.None);
            var handler     = new MutableObjectHandler(
                new List <IMutableObject> {
                objectProbe
            }
                );

            handler.SetInitialMutableObjectValues();

            Assert.AreEqual(1, objectProbe.ResetCount);
        }
Beispiel #4
0
 private static void RegisterSceneListeners(MutableObjectHandler handler)
 {
     SceneManager.activeSceneChanged += (curr, next) => handler.ResetActiveSceneChange();
     SceneManager.sceneUnloaded      += scene => handler.ResetSceneUnloaded();
     SceneManager.sceneLoaded        += (scene, mode) => handler.ResetSceneLoaded();
 }