コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldKernelPanicIfNotAbleToWriteACheckPoint() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldKernelPanicIfNotAbleToWriteACheckPoint()
        {
            // Given
            IOException ioex = new IOException("boom!");
            FlushablePositionAwareChannel channel = mock(typeof(FlushablePositionAwareChannel), RETURNS_MOCKS);

            when(channel.Put(anyByte())).thenReturn(channel);
            when(channel.PutLong(anyLong())).thenThrow(ioex);
            when(channel.Put(anyByte())).thenThrow(ioex);
            when(_logFile.Writer).thenReturn(channel);
            BatchingTransactionAppender appender = Life.add(CreateTransactionAppender());

            // When
            try
            {
                appender.CheckPoint(new LogPosition(0L, 0L), LogCheckPointEvent.NULL);
                fail("should have thrown ");
            }
            catch (IOException ex)
            {
                assertEquals(ioex, ex);
            }

            // Then
            verify(_databaseHealth, times(1)).panic(ioex);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToWriteACheckPoint() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeAbleToWriteACheckPoint()
        {
            // Given
            FlushablePositionAwareChannel channel = mock(typeof(FlushablePositionAwareChannel), RETURNS_MOCKS);
            Flushable flushable = mock(typeof(Flushable));

            when(channel.PrepareForFlush()).thenReturn(flushable);
            when(channel.PutLong(anyLong())).thenReturn(channel);
            when(_logFile.Writer).thenReturn(channel);
            BatchingTransactionAppender appender = Life.add(CreateTransactionAppender());

            // When
            appender.CheckPoint(new LogPosition(1L, 2L), LogCheckPointEvent.NULL);

            // Then
            verify(channel, times(1)).putLong(1L);
            verify(channel, times(1)).putLong(2L);
            verify(channel, times(1)).prepareForFlush();
            verify(flushable, times(1)).flush();
            verify(_databaseHealth, never()).panic(any());
        }