private void Awake() { if (instance != null) { Destroy(gameObject); } else { instance = this; DontDestroyOnLoad(gameObject); } }
public SingletonListenerTests() { MethodInfo methodInfo = this.GetType().GetMethod("TestJob", BindingFlags.Static | BindingFlags.NonPublic); _attribute = new SingletonAttribute(); _config = new SingletonConfiguration { LockPeriod = TimeSpan.FromSeconds(20) }; _mockSingletonManager = new Mock <SingletonManager>(MockBehavior.Strict); _mockSingletonManager.SetupGet(p => p.Config).Returns(_config); _mockInnerListener = new Mock <IListener>(MockBehavior.Strict); _listener = new SingletonListener(methodInfo, _attribute, _mockSingletonManager.Object, _mockInnerListener.Object); _lockId = SingletonManager.FormatLockId(methodInfo, _attribute.Scope) + ".Listener"; }
public SingletonListenerTests() { MethodInfo methodInfo = this.GetType().GetMethod("TestJob", BindingFlags.Static | BindingFlags.NonPublic); _attribute = new SingletonAttribute(); _config = new SingletonConfiguration { LockPeriod = TimeSpan.FromSeconds(20) }; _mockSingletonManager = new Mock <SingletonManager>(MockBehavior.Strict, null, null, null, null, new FixedHostIdProvider(TestHostId), null); _mockSingletonManager.SetupGet(p => p.Config).Returns(_config); _mockInnerListener = new Mock <IListener>(MockBehavior.Strict); _listener = new SingletonListener(methodInfo, _attribute, _mockSingletonManager.Object, _mockInnerListener.Object, new TestTraceWriter(System.Diagnostics.TraceLevel.Verbose)); _lockId = SingletonManager.FormatLockId(methodInfo, SingletonScope.Function, TestHostId, _attribute.ScopeId) + ".Listener"; }
public SingletonListenerTests() { MethodInfo methodInfo = this.GetType().GetMethod("TestJob", BindingFlags.Static | BindingFlags.NonPublic); var descriptor = FunctionIndexer.FromMethod(methodInfo); _attribute = new SingletonAttribute(); _config = new SingletonConfiguration { LockPeriod = TimeSpan.FromSeconds(20) }; _mockSingletonManager = new Mock <SingletonManager>(MockBehavior.Strict, null, null, null, null, new FixedHostIdProvider(testHostId), null); _mockSingletonManager.SetupGet(p => p.Config).Returns(_config); _mockInnerListener = new Mock <IListener>(MockBehavior.Strict); _listener = new SingletonListener(descriptor, _attribute, _mockSingletonManager.Object, _mockInnerListener.Object, null); _lockId = SingletonManager.FormatLockId(descriptor, SingletonScope.Function, testHostId, _attribute.ScopeId) + ".Listener"; }