Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotThrowNPEWhenAskedToFulFilledButNotYetHavingARoleAssigned() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotThrowNPEWhenAskedToFulFilledButNotYetHavingARoleAssigned()
        {
            // Given
            UpdatePullingTransactionObligationFulfiller fulfiller = new UpdatePullingTransactionObligationFulfiller(_updatePuller, _machine, _serverId, Suppliers.singleton(mock(typeof(TransactionIdStore))));

            // When
            fulfiller.Fulfill(1);

            // Then
            // it doesn't blow up
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUpdateTransactionIdStoreCorrectly() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUpdateTransactionIdStoreCorrectly()
        {
            // Given
            TransactionIdStore store1 = mock(typeof(TransactionIdStore));
            TransactionIdStore store2 = mock(typeof(TransactionIdStore));

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") System.Func<org.neo4j.kernel.impl.transaction.log.TransactionIdStore> supplier = mock(System.Func.class);
            System.Func <TransactionIdStore> supplier = mock(typeof(System.Func));
            when(supplier()).thenReturn(store1, store2);

            doAnswer(invocation =>
            {
                (( HighAvailabilityMemberListener )invocation.getArgument(0)).slaveIsAvailable(new HighAvailabilityMemberChangeEvent(null, null, _serverId, null)
                                                                                               );
                return(null);
            }).when(_machine).addHighAvailabilityMemberListener(any(typeof(HighAvailabilityMemberListener)));

            doAnswer(invocation =>
            {
                (( HighAvailabilityMemberListener )invocation.getArgument(0)).instanceStops(new HighAvailabilityMemberChangeEvent(null, null, _serverId, null)
                                                                                            );
                return(null);
            }).when(_machine).removeHighAvailabilityMemberListener(any(typeof(HighAvailabilityMemberListener)));

            UpdatePullingTransactionObligationFulfiller fulfiller = new UpdatePullingTransactionObligationFulfiller(_updatePuller, _machine, _serverId, supplier);

            // When
            fulfiller.Start();
            fulfiller.Fulfill(1);
            fulfiller.Stop();
            fulfiller.Fulfill(2);
            fulfiller.Start();
            fulfiller.Fulfill(3);
            fulfiller.Stop();
            fulfiller.Fulfill(4);

            // Then
            verify(store1, times(1)).LastClosedTransactionId;
            verify(store2, times(1)).LastClosedTransactionId;
        }