コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPerformSuccessfulStoreCopyProcess() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPerformSuccessfulStoreCopyProcess()
        {
            // given
            StoreStreamingProcess process = new StoreStreamingProcess(_protocol, _checkPointerSupplier, _mutex, _resourceStream);

            // mocked behaviour
            ImmediateEventExecutor eventExecutor     = ImmediateEventExecutor.INSTANCE;
            Promise <Void>         completionPromise = eventExecutor.newPromise();
            long lastCheckpointedTxId = 1000L;
            RawCursor <StoreResource, IOException> resources = rawCursorOf();

            when(_checkPointer.tryCheckPoint(any())).thenReturn(lastCheckpointedTxId);
            when(_checkPointer.lastCheckPointedTransactionId()).thenReturn(lastCheckpointedTxId);
            when(_protocol.end(_ctx, SUCCESS)).thenReturn(completionPromise);
            when(_resourceStream.create()).thenReturn(resources);

            // when
            process.Perform(_ctx);

            // then
            InOrder inOrder = Mockito.inOrder(_protocol, _checkPointer);

            inOrder.verify(_checkPointer).tryCheckPoint(any());
            inOrder.verify(_protocol).end(_ctx, SUCCESS);
            inOrder.verifyNoMoreInteractions();

            assertEquals(1, @lock.ReadLockCount);

            // when
            completionPromise.Success = null;

            // then
            assertEquals(0, @lock.ReadLockCount);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testSucceess()
        public virtual void testSucceess()
        {
            // given
            foo.getFoo();
            foo.Bar;

            // when
            InOrder inOrder = Mockito.inOrder(foo);

            inOrder.verify(foo).Foo;

            // then
            inOrder.verify(foo, immediatelyAfter()).Bar;
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testFailureWhenInvocationNotPresentCase2()
        public virtual void testFailureWhenInvocationNotPresentCase2()
        {
            // given
            foo.getFoo();

            // when
            InOrder inOrder = Mockito.inOrder(foo);

            inOrder.verify(foo).Foo;

            // then
            try
            {
                inOrder.verify(foo, immediatelyAfter()).Bar;
                Assert.fail("should not verify");
            }
            catch (MockitoAssertionError)
            {
                // happy path
            }
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogAndDumpData() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogAndDumpData()
        {
            // given
            DatabaseLayout        databaseLayout = this.Directory.databaseLayout();
            LabelScanWriteMonitor writeMonitor   = new LabelScanWriteMonitor(Fs, databaseLayout);
            LabelScanValue        value          = new LabelScanValue();

            writeMonitor.Range(3, 0);
            writeMonitor.PrepareAdd(123, 4);
            writeMonitor.PrepareAdd(123, 5);
            writeMonitor.MergeAdd(new LabelScanValue(), value.Set(4).set(5));
            writeMonitor.FlushPendingUpdates();
            writeMonitor.PrepareRemove(124, 5);
            writeMonitor.MergeRemove(value, (new LabelScanValue()).Set(5));
            writeMonitor.WriteSessionEnded();
            writeMonitor.Range(5, 1);
            writeMonitor.PrepareAdd(125, 10);
            writeMonitor.MergeAdd((new LabelScanValue()).Set(9), (new LabelScanValue()).Set(10));
            writeMonitor.FlushPendingUpdates();
            writeMonitor.WriteSessionEnded();
            writeMonitor.Close();

            // when
            LabelScanWriteMonitor.Dumper dumper = mock(typeof(LabelScanWriteMonitor.Dumper));
            LabelScanWriteMonitor.Dump(Fs, databaseLayout, dumper, null);

            // then
            InOrder inOrder = Mockito.inOrder(dumper);

            inOrder.verify(dumper).prepare(true, 0, 0, 123, 64 * 3 + 4, 0);
            inOrder.verify(dumper).prepare(true, 0, 0, 123, 64 * 3 + 5, 0);
            inOrder.verify(dumper).merge(true, 0, 0, 3, 0, 0, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000000_00110000);
            inOrder.verify(dumper).prepare(false, 0, 1, 124, 64 * 3 + 5, 0);
            inOrder.verify(dumper).merge(false, 0, 1, 3, 0, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000000_00110000, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000000_00100000);
            inOrder.verify(dumper).prepare(true, 1, 0, 125, 64 * 5 + 10, 1);
            inOrder.verify(dumper).merge(true, 1, 0, 5, 1, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000010_00000000, 0b00000000_0000000_00000000_00000000__00000000_00000000_00000100_00000000);
            inOrder.verifyNoMoreInteractions();
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLetGatedMessagesPassOnSuccess() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLetGatedMessagesPassOnSuccess()
        {
            // given
            ChannelPromise promiseA = mock(typeof(ChannelPromise));
            ChannelPromise promiseB = mock(typeof(ChannelPromise));
            ChannelPromise promiseC = mock(typeof(ChannelPromise));

            _gate.write(_ctx, "A", promiseA);
            _gate.write(_ctx, "B", promiseB);
            _gate.write(_ctx, "C", promiseC);
            verify(_ctx, never()).write(any(), any());

            // when
            _gate.userEventTriggered(_ctx, GateEvent.Success);

            // then
            InOrder inOrder = Mockito.inOrder(_ctx);

            inOrder.verify(_ctx).write("A", promiseA);
            inOrder.verify(_ctx).write("B", promiseB);
            inOrder.verify(_ctx).write("C", promiseC);
            inOrder.verify(_ctx, never()).write(any(), any());
        }