public void CanSaveAndLoadSessionStateKeys() { m_Manager.Initialize(m_Settings); m_Manager.GlobalProfileVariables.Clear(); var customIps = new Dictionary <string, string>() { { m_Manager.GetPrivateIpAddressKey(0), "111.1.1.1" }, { m_Manager.GetPrivateIpAddressKey(1), "222.2.2.2" }, { m_Manager.GetPrivateIpAddressKey(2), "333.3.3.3" }, }; foreach (KeyValuePair <string, string> pair in customIps) { m_Manager.GlobalProfileVariables.Add(pair.Key, pair.Value); } m_Manager.SaveSessionStateKeys(); m_Manager.GlobalProfileVariables.Clear(); m_Manager.LoadSessionStateKeys(); Assert.AreEqual(customIps.Count, m_Manager.GlobalProfileVariables.Count); foreach (KeyValuePair <string, string> pair in customIps) { Assert.IsTrue(m_Manager.GlobalProfileVariables.ContainsKey(pair.Key)); Assert.AreEqual(pair.Value, m_Manager.GlobalProfileVariables[pair.Key]); } HostingServicesManager.EraseSessionStateKeys(); }
public void OnEnableShould_UnregisterProfileStringEvalFuncForManager() { m_Manager.Initialize(m_Settings); m_Manager.OnEnable(); Assert.IsTrue(ProfileStringEvalDelegateIsRegistered(m_Settings, m_Manager)); m_Manager.OnDisable(); Assert.IsFalse(ProfileStringEvalDelegateIsRegistered(m_Settings, m_Manager)); HostingServicesManager.EraseSessionStateKeys(); }
public void OnDisableShould_DeRegisterProfileStringEvalFuncsForServices() { m_Manager.Initialize(m_Settings); var svc = m_Manager.AddHostingService(typeof(TestHostingService), "test") as TestHostingService; Assert.IsNotNull(svc); m_Manager.Initialize(m_Settings); m_Manager.OnEnable(); Assert.IsTrue(ProfileStringEvalDelegateIsRegistered(m_Settings, svc)); m_Manager.OnDisable(); Assert.IsFalse(ProfileStringEvalDelegateIsRegistered(m_Settings, svc)); HostingServicesManager.EraseSessionStateKeys(); }
public void OnDisableShould_RegisterNullLoggerForServices() { m_Manager.Initialize(m_Settings); var svc = m_Manager.AddHostingService(typeof(TestHostingService), "test") as TestHostingService; Assert.IsNotNull(svc); m_Manager.Initialize(m_Settings); m_Manager.OnEnable(); Assert.IsNotNull(svc.Logger); m_Manager.OnDisable(); Assert.IsNull(svc.Logger); HostingServicesManager.EraseSessionStateKeys(); }
public void OnDisableShould_DeRegisterForSettingsModificationEvents() { var len = m_Settings.OnModification.GetInvocationList().Length; m_Manager.Initialize(m_Settings); m_Manager.OnEnable(); m_Manager.OnEnable(); m_Manager.OnEnable(); Assert.Greater(m_Settings.OnModification.GetInvocationList().Length, len); m_Manager.OnDisable(); Assert.AreEqual(len, m_Settings.OnModification.GetInvocationList().Length); HostingServicesManager.EraseSessionStateKeys(); }
public void CanEraseSessionStateKeys() { m_Manager.Initialize(m_Settings); m_Manager.GlobalProfileVariables.Clear(); m_Manager.GlobalProfileVariables.Add(m_Manager.GetPrivateIpAddressKey(0), "111.1.1.1"); m_Manager.GlobalProfileVariables.Add(m_Manager.GetPrivateIpAddressKey(1), "222.2.2.2"); m_Manager.GlobalProfileVariables.Add(m_Manager.GetPrivateIpAddressKey(2), "333.3.3.3"); m_Manager.SaveSessionStateKeys(); HostingServicesManager.EraseSessionStateKeys(); Assert.AreEqual(string.Empty, SessionState.GetString(HostingServicesManager.GetSessionStateKey(0), string.Empty)); Assert.AreEqual(string.Empty, SessionState.GetString(HostingServicesManager.GetSessionStateKey(1), string.Empty)); Assert.AreEqual(string.Empty, SessionState.GetString(HostingServicesManager.GetSessionStateKey(2), string.Empty)); }
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(); }
public void OnDisableShould_StopAllServices() { m_Manager.Initialize(m_Settings); for (int i = 0; i < 3; i++) { var svc = m_Manager.AddHostingService(typeof(HttpHostingService), $"test_{i}") as HttpHostingService; Assert.IsNotNull(svc); svc.StartHostingService(); Assert.IsTrue(svc.IsHostingServiceRunning); } m_Manager.OnDisable(); foreach (var svc in m_Manager.HostingServices) { Assert.IsFalse(svc.IsHostingServiceRunning); } HostingServicesManager.EraseSessionStateKeys(); }
public void OnDisableShould_SaveSessionStateKeys() { string ipAddressKey = m_Manager.GetPrivateIpAddressKey(0); string ipAddressVal = "123.1.2.3"; m_Manager.Initialize(m_Settings); m_Manager.GlobalProfileVariables.Clear(); m_Manager.GlobalProfileVariables.Add(ipAddressKey, ipAddressVal); m_Manager.OnDisable(); m_Manager.GlobalProfileVariables.Clear(); m_Manager.LoadSessionStateKeys(); Assert.AreEqual(1, m_Manager.GlobalProfileVariables.Count); Assert.IsTrue(m_Manager.GlobalProfileVariables.ContainsKey(ipAddressKey)); Assert.AreEqual(ipAddressVal, m_Manager.GlobalProfileVariables[ipAddressKey]); HostingServicesManager.EraseSessionStateKeys(); }
public void LoadSessionStateKeys_ExcludesMissingKeys() { string ipAddressKey = m_Manager.GetPrivateIpAddressKey(1); m_Manager.Initialize(m_Settings); m_Manager.GlobalProfileVariables.Clear(); m_Manager.GlobalProfileVariables.Add(m_Manager.GetPrivateIpAddressKey(0), "111.1.1.1"); m_Manager.GlobalProfileVariables.Add(ipAddressKey, "222.2.2.2"); m_Manager.GlobalProfileVariables.Add(m_Manager.GetPrivateIpAddressKey(2), "333.3.3.3"); m_Manager.SaveSessionStateKeys(); m_Manager.GlobalProfileVariables.Clear(); SessionState.EraseString(HostingServicesManager.GetSessionStateKey(1)); m_Manager.LoadSessionStateKeys(); Assert.AreEqual(2, m_Manager.GlobalProfileVariables.Count); Assert.IsFalse(m_Manager.GlobalProfileVariables.ContainsKey(ipAddressKey)); HostingServicesManager.EraseSessionStateKeys(); }
public void OnDomainReload_HttpServicePortShouldntChange() { m_Manager.Initialize(m_Settings); var svc = m_Manager.AddHostingService(typeof(HttpHostingService), "test") as HttpHostingService; Assert.IsNotNull(svc); svc.WasEnabled = true; m_Manager.OnEnable(); var expectedPort = svc.HostingServicePort; Assert.IsTrue(svc.IsHostingServiceRunning); for (int i = 1; i <= 5; i++) { m_Manager.OnDisable(); Assert.IsFalse(svc.IsHostingServiceRunning, $"Service '{svc.DescriptiveName}' was still running after manager.OnDisable() (iteration {i}"); m_Manager.OnEnable(); Assert.IsTrue(svc.IsHostingServiceRunning, $"Service '{svc.DescriptiveName}' not running after manager.OnEnable() (iteration {i}"); } Assert.AreEqual(expectedPort, svc.HostingServicePort); HostingServicesManager.EraseSessionStateKeys(); }
public void OneTimeSetUp() { // calling EditorSceneManager.NewScene from other tests will call HostingServicesManager.OnDisable and save the keys HostingServicesManager.EraseSessionStateKeys(); }