Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReportMain()
        public virtual void MustReportMain()
        {
            // given
            AssertableLogProvider logProvider = new AssertableLogProvider(true);
            Log          log          = logProvider.GetLog(typeof(IndexPopulationJob));
            PhaseTracker phaseTracker = GetPhaseTracker(log);

            phaseTracker.EnterPhase(PhaseTracker_Phase.Scan);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Write);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Scan);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Write);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Merge);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Build);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.ApplyExternal);
            Sleep(100);
            phaseTracker.EnterPhase(PhaseTracker_Phase.Flip);
            Sleep(100);

            // when
            phaseTracker.Stop();

            // then
            AssertableLogProvider.LogMatcher logMatcher = AssertableLogProvider.inLog(typeof(IndexPopulationJob)).info("TIME/PHASE Final: " + "SCAN[totalTime=200ms, avgTime=100ms, minTime=0ns, maxTime=100ms, nbrOfReports=2], " + "WRITE[totalTime=200ms, avgTime=100ms, minTime=0ns, maxTime=100ms, nbrOfReports=2], " + "MERGE[totalTime=100ms], BUILD[totalTime=100ms], APPLY_EXTERNAL[totalTime=100ms], FLIP[totalTime=100ms]");
            logProvider.AssertAtLeastOnce(logMatcher);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void throwIfEnterAfterStop()
        public virtual void ThrowIfEnterAfterStop()
        {
            PhaseTracker phaseTracker = PhaseTracker;

            phaseTracker.Stop();
            try
            {
                phaseTracker.EnterPhase(PhaseTracker_Phase.Scan);
                fail("Should have failed");
            }
            catch (System.InvalidOperationException e)
            {
                assertThat(e.Message, containsString("Trying to report a new phase after phase tracker has been stopped."));
            }
        }