示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogElectionProcess()
        public virtual void ShouldLogElectionProcess()
        {
            // given
            ClusterContext clusterContext = mock(typeof(ClusterContext));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.logging.Log log = mock(org.neo4j.logging.Log.class);
            Log         log         = mock(typeof(Log));
            LogProvider logProvider = new LogProviderAnonymousInnerClass(this, log);

            when(clusterContext.GetLog(typeof(DefaultWinnerStrategy))).thenReturn(logProvider.GetLog(typeof(DefaultWinnerStrategy)));

            // when
            ICollection <Vote> votes = Collections.emptyList();

            DefaultWinnerStrategy strategy = new DefaultWinnerStrategy(clusterContext);

            strategy.PickWinner(votes);

            // then
            verify(log).debug("Election: received votes [], eligible votes []");
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotPickAWinnerIfAllVotesAreForIneligibleCandidates()
        public virtual void ShouldNotPickAWinnerIfAllVotesAreForIneligibleCandidates()
        {
            // given
            InstanceId instanceOne = new InstanceId(1);
            InstanceId instanceTwo = new InstanceId(2);

            ClusterContext clusterContext = mock(typeof(ClusterContext));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.logging.Log log = mock(org.neo4j.logging.Log.class);
            Log         log         = mock(typeof(Log));
            LogProvider logProvider = new LogProviderAnonymousInnerClass2(this, log);

            when(clusterContext.GetLog(typeof(DefaultWinnerStrategy))).thenReturn(logProvider.GetLog(typeof(DefaultWinnerStrategy)));

            // when
            ICollection <Vote> votes = Arrays.asList(new Vote(instanceOne, new NotElectableElectionCredentials()), new Vote(instanceTwo, new NotElectableElectionCredentials()));

            DefaultWinnerStrategy strategy = new DefaultWinnerStrategy(clusterContext);
            InstanceId            winner   = strategy.PickWinner(votes);

            // then
            assertNull(winner);
        }