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 shouldCleanMultipleCrashPerPage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCleanMultipleCrashPerPage()
        {
            // GIVEN
            Page[] pages = With(LeafWith(GBPTreeCorruption.Crashed(GBPTreePointerType.leftSibling()), GBPTreeCorruption.Crashed(GBPTreePointerType.rightSibling()), GBPTreeCorruption.Crashed(GBPTreePointerType.successor())), InternalWith(GBPTreeCorruption.Crashed(GBPTreePointerType.leftSibling()), GBPTreeCorruption.Crashed(GBPTreePointerType.rightSibling()), GBPTreeCorruption.Crashed(GBPTreePointerType.successor()), GBPTreeCorruption.Crashed(GBPTreePointerType.child(0))));
            InitializeFile(_pagedFile, pages);

            // WHEN
            SimpleCleanupMonitor monitor = new SimpleCleanupMonitor();

            CrashGenerationCleaner(_pagedFile, 0, pages.Length, monitor).clean(_executor);

            // THEN
            AssertPagesVisited(monitor, pages.Length);
            AssertCleanedCrashPointers(monitor, 7);
        }
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 shouldNotReportErrorsOnCleanPages() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotReportErrorsOnCleanPages()
        {
            // GIVEN
            Page[] pages = With(LeafWith(), InternalWith());
            InitializeFile(_pagedFile, pages);

            // WHEN
            SimpleCleanupMonitor monitor = new SimpleCleanupMonitor();

            CrashGenerationCleaner(_pagedFile, 0, pages.Length, monitor).clean(_executor);

            // THEN
            AssertPagesVisited(monitor, 2);
            AssertCleanedCrashPointers(monitor, 0);
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotCrashOnEmptyFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotCrashOnEmptyFile()
        {
            // GIVEN
            Page[] pages = With();
            InitializeFile(_pagedFile, pages);

            // WHEN
            SimpleCleanupMonitor monitor = new SimpleCleanupMonitor();

            CrashGenerationCleaner(_pagedFile, 0, pages.Length, monitor).clean(_executor);

            // THEN
            AssertPagesVisited(monitor, pages.Length);
            AssertCleanedCrashPointers(monitor, 0);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCleanLargeFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCleanLargeFile()
        {
            // GIVEN
            int        numberOfPages            = _randomRule.intBetween(1_000, 10_000);
            int        corruptionPercent        = _randomRule.Next(90);
            MutableInt totalNumberOfCorruptions = new MutableInt(0);

            Page[] pages = new Page[numberOfPages];
            for (int i = 0; i < numberOfPages; i++)
            {
                Page page = RandomPage(corruptionPercent, totalNumberOfCorruptions);
                pages[i] = page;
            }
            InitializeFile(_pagedFile, pages);

            // WHEN
            SimpleCleanupMonitor monitor = new SimpleCleanupMonitor();

            CrashGenerationCleaner(_pagedFile, 0, numberOfPages, monitor).clean(_executor);

            // THEN
            AssertPagesVisited(monitor, numberOfPages);
            AssertCleanedCrashPointers(monitor, totalNumberOfCorruptions.Value);
        }
Esempio n. 5
0
 private void AssertPagesVisited(SimpleCleanupMonitor monitor, int expectedNumberOfPagesVisited)
 {
     assertEquals("Expected number of visited pages to be " + expectedNumberOfPagesVisited + " but was " + monitor.NumberOfPagesVisited, expectedNumberOfPagesVisited, monitor.NumberOfPagesVisited);
 }
Esempio n. 6
0
 /* Assertions */
 private void AssertCleanedCrashPointers(SimpleCleanupMonitor monitor, int expectedNumberOfCleanedCrashPointers)
 {
     assertEquals("Expected number of cleaned crash pointers to be " + expectedNumberOfCleanedCrashPointers + " but was " + monitor.NumberOfCleanedCrashPointers, expectedNumberOfCleanedCrashPointers, monitor.NumberOfCleanedCrashPointers);
 }
Esempio n. 7
0
 private CrashGenerationCleaner CrashGenerationCleaner(PagedFile pagedFile, int lowTreeNodeId, int highTreeNodeId, SimpleCleanupMonitor monitor)
 {
     return(new CrashGenerationCleaner(pagedFile, _treeNode, lowTreeNodeId, highTreeNodeId, _unstableTreeState.stableGeneration(), _unstableTreeState.unstableGeneration(), monitor));
 }