コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void baseNoSendTest(java.util.Map<org.neo4j.cluster.InstanceId,java.net.URI> extraMembers) throws Throwable
        private void BaseNoSendTest(IDictionary <InstanceId, URI> extraMembers)
        {
            URI me = URI.create("cluster://me");

            IDictionary <InstanceId, URI> members = new Dictionary <InstanceId, URI>();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.cluster.InstanceId myId = new org.neo4j.cluster.InstanceId(1);
            InstanceId myId = new InstanceId(1);

            members[myId] = me;
//JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method:
            members.putAll(extraMembers);

            ClusterConfiguration clusterConfiguration = mock(typeof(ClusterConfiguration));

            when(clusterConfiguration.Members).thenReturn(members);
            when(clusterConfiguration.GetElected(ClusterConfiguration.COORDINATOR)).thenReturn(myId);
            when(clusterConfiguration.GetUriForId(myId)).thenReturn(me);

            ClusterContext clusterContext = mock(typeof(ClusterContext));

            when(clusterContext.Configuration).thenReturn(clusterConfiguration);
            when(clusterContext.MyId).thenReturn(myId);

            SnapshotContext context = mock(typeof(SnapshotContext));

            when(context.ClusterContext).thenReturn(clusterContext);
            SnapshotProvider snapshotProvider = mock(typeof(SnapshotProvider));

            when(context.SnapshotProvider).thenReturn(snapshotProvider);

            Message <SnapshotMessage> message = Message.to(SnapshotMessage.RefreshSnapshot, me);

            MessageHolder outgoing = mock(typeof(MessageHolder));

            SnapshotState newState = ( SnapshotState )SnapshotState.Ready.handle(context, message, outgoing);

            assertThat(newState, equalTo(SnapshotState.Ready));
            Mockito.verifyZeroInteractions(outgoing);
        }