public void OnEnableShould_LoadSessionStateKeys_IfExitingEditMode_AndConditionsAreMet(bool serviceEnabled, bool usingPackedPlayMode) { string ipAddressKey = m_Manager.GetPrivateIpAddressKey(); string ipAddressVal = "123.1.2.3"; m_Manager.Initialize(m_Settings); bool exitingExitMode = m_Manager.exitingEditMode; m_Manager.exitingEditMode = true; var svc = m_Manager.AddHostingService(typeof(TestHostingService), "test"); if (serviceEnabled) { svc.StartHostingService(); } int activePlayerDataBuilderIndex = m_Settings.ActivePlayModeDataBuilderIndex; if (usingPackedPlayMode) { m_Settings.DataBuilders.Add(ScriptableObject.CreateInstance <BuildScriptPackedPlayMode>()); m_Settings.ActivePlayModeDataBuilderIndex = m_Settings.DataBuilders.Count - 1; } m_Manager.GlobalProfileVariables.Clear(); m_Manager.GlobalProfileVariables.Add(ipAddressKey, ipAddressVal); m_Manager.SaveSessionStateKeys(); m_Manager.GlobalProfileVariables.Clear(); m_Manager.OnEnable(); Assert.AreEqual(1, m_Manager.GlobalProfileVariables.Count); Assert.IsTrue(m_Manager.GlobalProfileVariables.ContainsKey(ipAddressKey)); Assert.AreEqual(ipAddressVal, m_Manager.GlobalProfileVariables[ipAddressKey]); if (serviceEnabled) { svc.StopHostingService(); } m_Settings.ActivePlayModeDataBuilderIndex = activePlayerDataBuilderIndex; if (usingPackedPlayMode) { m_Settings.DataBuilders.RemoveAt(m_Settings.DataBuilders.Count - 1); } m_Manager.exitingEditMode = exitingExitMode; HostingServicesManager.EraseSessionStateKeys(); }