public void MemberRemovedEvent() { var reset = new ManualResetEventSlim(); _client.GetCluster().AddMembershipListener(new MembershipListener { OnMemberAdded = memberAddedEvent => { reset.Set(); } }); var member = StartMember(_remoteController, _cluster); Assert.IsTrue(reset.Wait(30 * 1000)); reset.Reset(); MembershipEvent memberRemovedEvent = null; _client.GetCluster().AddMembershipListener(new MembershipListener { OnMemberRemoved = memberRemoved => { memberRemovedEvent = memberRemoved; reset.Set(); } }); StopMember(_remoteController, _cluster, member); Assert.IsTrue(reset.Wait(30 * 1000)); Assert.IsInstanceOf <ICluster>(memberRemovedEvent.Source); Assert.IsInstanceOf <ICluster>(memberRemovedEvent.GetCluster()); Assert.AreEqual(MembershipEvent.MemberRemoved, memberRemovedEvent.GetEventType()); Assert.IsNotNull(memberRemovedEvent.GetMember()); Assert.AreEqual(1, memberRemovedEvent.GetMembers().Count); }
public void MemberRemovedEvent() { var node = Cluster.AddNode(); Client.GetCluster().AddMembershipListener(new MembershipListener { OnMemberAdded = memberAddedEvent => { Cluster.RemoveNode(node); } }); var reset = new ManualResetEventSlim(); MembershipEvent memberRemovedEvent = null; Client.GetCluster().AddMembershipListener(new MembershipListener { OnMemberRemoved = memberRemoved => { memberRemovedEvent = memberRemoved; reset.Set(); } }); Assert.IsTrue(reset.Wait(30 * 1000)); Assert.IsInstanceOf <ICluster>(memberRemovedEvent.Source); Assert.IsInstanceOf <ICluster>(memberRemovedEvent.GetCluster()); Assert.AreEqual(MembershipEvent.MemberRemoved, memberRemovedEvent.GetEventType()); Assert.IsNotNull(memberRemovedEvent.GetMember()); Assert.AreEqual(1, memberRemovedEvent.GetMembers().Count); }