internal void _Join(Peer peer, IBootable bootable) { lock(_Peers) _Peers.Add(peer); peer.DisconnectEvent += () => { _Leave(peer, peer); }; bootable.Launch(); }
internal void _Join(Peer peer, IBootable bootable) { lock (_Peers) { _Peers.Add(peer); peer.DisconnectEvent += () => { _Leave(peer, peer); }; } bootable.Launch(); }
internal void _Leave(Peer peer, IBootable bootable) { lock(_Peers) { if (_Peers.Remove(peer)) { bootable.Shutdown(); } else { throw new Exception("no peer shutdown."); } } }
internal void _Leave(Peer peer, IBootable bootable) { lock (_Peers) { if (_Peers.Remove(peer)) { bootable.Shutdown(); } else { if (_Peers.Count > 0) { throw new Exception("no peer shutdown."); } } } }
public void TestGPIBinder() { Command command = new Command(); IBinderTest tester = Substitute.For <IBinderTest>(); TestNotifier notifier = new TestNotifier(tester); GPIBinder <IBinderTest> binder = new GPIBinder <IBinderTest>(notifier, command); IBootable boot = binder; boot.Launch(); binder.Bind(t => t.Function1()); binder.Bind <int>((t, arg) => t.Function2(arg)); bool returnValue = false; int returnProperty = 0; binder.Bind(t => t.Function3(), ret => { returnValue = true; }); binder.Bind(t => t.Property1, ret => { returnProperty = 12345; }); notifier.InvokeSupply(); command.Run("0Function1", new string[0]); command.Run("0Function2", new string[] { "10" }); command.Run("0Function3", new string[0]); command.Run("0Property1", new string[0]); boot.Shutdown(); tester.Received().Function1(); tester.Received().Function2(Arg.Any <int>()); NUnit.Framework.Assert.AreEqual(true, returnValue); NUnit.Framework.Assert.AreEqual(12345, returnProperty); }
public void Push(IBootable laucnher) { _Launchers.Add(laucnher); }