Exemplo n.º 1
0
 private void ExpectCallsToCheck(ExecutionMonitor multiMonitor, params object[] alternatingMonitorAndCount)
 {
     multiMonitor.Check(null);                 // null, knowing that our monitors in this test doesn't use 'em
     for (int i = 0; i < alternatingMonitorAndCount.Length; i++)
     {
         TestableMonitor monitor = ( TestableMonitor )alternatingMonitorAndCount[i++];
         int             count   = ( int? )alternatingMonitorAndCount[i].Value;
         assertThat(monitor.TimesPolled, lessThanOrEqualTo(count));
         if (monitor.TimesPolled < count)
         {
             fail("Polls didn't occur, expected " + Arrays.ToString(alternatingMonitorAndCount));
         }
     }
 }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCheckMultipleMonitors()
        public virtual void ShouldCheckMultipleMonitors()
        {
            // GIVEN
            FakeClock             clock        = Clocks.fakeClock();
            TestableMonitor       first        = new TestableMonitor(clock, 100, MILLISECONDS, "first");
            TestableMonitor       other        = new TestableMonitor(clock, 250, MILLISECONDS, "other");
            MultiExecutionMonitor multiMonitor = new MultiExecutionMonitor(clock, first, other);

            // WHEN/THEN
            clock.Forward(110, MILLISECONDS);
            ExpectCallsToCheck(multiMonitor, first, 1, other, 0);
            clock.Forward(100, MILLISECONDS);
            ExpectCallsToCheck(multiMonitor, first, 2, other, 0);
            clock.Forward(45, MILLISECONDS);
            ExpectCallsToCheck(multiMonitor, first, 2, other, 1);
        }