//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void instanceFailingShouldHaveItsVotesInvalidated() public virtual void InstanceFailingShouldHaveItsVotesInvalidated() { // Given const string role1 = "coordinator1"; const string role2 = "coordinator2"; InstanceId me = new InstanceId(1); InstanceId failingInstance = new InstanceId(2); InstanceId otherInstance = new InstanceId(3); Config config = mock(typeof(Config)); when(config.Get(ClusterSettings.max_acceptors)).thenReturn(10); ClusterConfiguration clusterConfiguration = mock(typeof(ClusterConfiguration)); IList <InstanceId> clusterMemberIds = new LinkedList <InstanceId>(); clusterMemberIds.Add(failingInstance); clusterMemberIds.Add(otherInstance); clusterMemberIds.Add(me); when(clusterConfiguration.MemberIds).thenReturn(clusterMemberIds); MultiPaxosContext context = new MultiPaxosContext(me, Iterables.iterable(new ElectionRole(role1), new ElectionRole(role2)), clusterConfiguration, ThreadStart.run, NullLogProvider.Instance, mock(typeof(ObjectInputStreamFactory)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(AcceptorInstanceStore)), mock(typeof(Timeouts)), mock(typeof(ElectionCredentialsProvider)), config); HeartbeatContext heartbeatContext = context.HeartbeatContext; ElectionContext electionContext = context.ElectionContext; electionContext.StartElectionProcess(role1); electionContext.StartElectionProcess(role2); electionContext.Voted(role1, failingInstance, mock(typeof(ElectionCredentials)), 2); electionContext.Voted(role2, failingInstance, mock(typeof(ElectionCredentials)), 2); electionContext.Voted(role1, otherInstance, mock(typeof(ElectionCredentials)), 2); electionContext.Voted(role2, otherInstance, mock(typeof(ElectionCredentials)), 2); heartbeatContext.Suspect(failingInstance); assertEquals(1, electionContext.GetVoteCount(role1)); assertEquals(1, electionContext.GetVoteCount(role2)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void twoVotesFromSameInstanceForSameRoleShouldBeConsolidated() public virtual void TwoVotesFromSameInstanceForSameRoleShouldBeConsolidated() { // Given const string coordinatorRole = "coordinator"; HeartbeatContext heartbeatContext = mock(typeof(HeartbeatContext)); when(heartbeatContext.Failed).thenReturn(Collections.emptySet()); IDictionary <InstanceId, URI> members = new Dictionary <InstanceId, URI>(); members[new InstanceId(1)] = URI.create("server1"); members[new InstanceId(2)] = URI.create("server2"); members[new InstanceId(3)] = URI.create("server3"); Config config = mock(typeof(Config)); when(config.Get(ClusterSettings.max_acceptors)).thenReturn(10); ClusterConfiguration clusterConfiguration = mock(typeof(ClusterConfiguration)); when(clusterConfiguration.Members).thenReturn(members); ClusterContext clusterContext = mock(typeof(ClusterContext)); when(clusterContext.Configuration).thenReturn(clusterConfiguration); MultiPaxosContext context = new MultiPaxosContext(new InstanceId(1), Iterables.iterable(new ElectionRole(coordinatorRole)), clusterConfiguration, mock(typeof(Executor)), NullLogProvider.Instance, mock(typeof(ObjectInputStreamFactory)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(AcceptorInstanceStore)), mock(typeof(Timeouts)), mock(typeof(ElectionCredentialsProvider)), config); ElectionContext toTest = context.ElectionContext; // When toTest.StartElectionProcess(coordinatorRole); toTest.Voted(coordinatorRole, new InstanceId(1), new IntegerElectionCredentials(100), Org.Neo4j.cluster.protocol.cluster.ClusterContext_Fields.NO_ELECTOR_VERSION); toTest.Voted(coordinatorRole, new InstanceId(2), new IntegerElectionCredentials(100), Org.Neo4j.cluster.protocol.cluster.ClusterContext_Fields.NO_ELECTOR_VERSION); toTest.Voted(coordinatorRole, new InstanceId(2), new IntegerElectionCredentials(101), Org.Neo4j.cluster.protocol.cluster.ClusterContext_Fields.NO_ELECTOR_VERSION); // Then assertNull(toTest.GetElectionWinner(coordinatorRole)); assertEquals(2, toTest.GetVoteCount(coordinatorRole)); }