Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEmptyIfTooMany() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldEmptyIfTooMany()
        {
            // GIVEN
            Applier          applier   = mock(typeof(Applier));
            int              batchSize = 10;
            TransactionQueue queue     = new TransactionQueue(batchSize, applier);

            // WHEN
            for (int i = 0; i < 9; i++)
            {
                queue.Queue(mock(typeof(TransactionToApply)));
                verifyNoMoreInteractions(applier);
            }
            queue.Queue(mock(typeof(TransactionToApply)));
            verify(applier, times(1)).apply(any(), any());
            reset(applier);

            // THEN
            queue.Queue(mock(typeof(TransactionToApply)));

            // and WHEN emptying in the end
            for (int i = 0; i < 2; i++)
            {
                queue.Queue(mock(typeof(TransactionToApply)));
                verifyNoMoreInteractions(applier);
            }
            queue.Empty();
            verify(applier, times(1)).apply(any(), any());
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLinkTogetherTransactions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLinkTogetherTransactions()
        {
            // GIVEN
            Applier          applier   = mock(typeof(Applier));
            int              batchSize = 10;
            TransactionQueue queue     = new TransactionQueue(batchSize, applier);

            // WHEN
            TransactionToApply[] txs = new TransactionToApply[batchSize];
            for (int i = 0; i < batchSize; i++)
            {
                queue.Queue(txs[i] = new TransactionToApply(mock(typeof(TransactionRepresentation))));
            }

            // THEN
            verify(applier, times(1)).apply(any(), any());
            for (int i = 0; i < txs.Length - 1; i++)
            {
                assertEquals(txs[i + 1], txs[i].Next());
            }
        }