Package org.fishwife.jrugged.interval

Examples of org.fishwife.jrugged.interval.DiscreteInterval


    }

    @Test
    public void isNotLateIfCurrentClockReadingIsPartiallyBeforeTargetRange() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L));
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(200L,1006L)).anyTimes();
        replay(mockClock);
        impl.set(1000L,100L);
        impl.start();
        assertFalse(impl.isLate());
        verify(mockClock);
View Full Code Here


    }

    @Test
    public void isNotLateIfCurrentClockReadingIsWithinTargetRange() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L));
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(1005L,1006L)).anyTimes();
        replay(mockClock);
        impl.set(1000L,100L);
        impl.start();
        assertFalse(impl.isLate());
        verify(mockClock);
View Full Code Here

    }

    @Test
    public void isLateIfCurrentClockReadingIsPartiallyBeyondTargetRange() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L));
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(1005L,2006L)).anyTimes();
        replay(mockClock);
        impl.set(1000L,100L);
        impl.start();
        assertTrue(impl.isLate());
        verify(mockClock);
View Full Code Here

    }

    @Test
    public void isLateIfCurrentClockReadingIsCompletelyBeyondTargetRange() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L));
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(2005L,2006L)).anyTimes();
        replay(mockClock);
        impl.set(1000L,100L);
        impl.start();
        assertTrue(impl.isLate());
        verify(mockClock);
View Full Code Here

    }

    @Test
    public void isNotLateIfNotStarted() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L)).anyTimes();
        replay(mockClock);
        impl.set(1000L,100L);
        assertFalse(impl.isLate());
        verify(mockClock);
    }
View Full Code Here

    }

    @Test
    public void timeRemainingTillElapsedIsDurationIfNotStarted() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L)).anyTimes();
        replay(mockClock);
        impl.set(1000L,100L);
        assertEquals(new DiscreteInterval(900L,1100L), impl.getTimeRemaining());
        verify(mockClock);
    }
View Full Code Here

    }
   
    @Test(expected=IllegalStateException.class)
    public void cannotAskForRemainingTimeIfNotSet() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L)).anyTimes();
        replay(mockClock);
        impl.getTimeRemaining();
    }
View Full Code Here

    }
   
    @Test
    public void hasFullTimeRemainingIfClockHasNotTicked() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L)).anyTimes();
        replay(mockClock);
        impl.set(1000L,100L);
        impl.start();
        assertEquals(new DiscreteInterval(899L,1101L), impl.getTimeRemaining());
        verify(mockClock);
    }
View Full Code Here

   
    @Test
    public void canComputePartialTimeRemaining() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L));
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(504L,505L)).anyTimes();
        replay(mockClock);
        impl.set(1000L,100L);
        impl.start();
        assertEquals(new DiscreteInterval(399L,601L), impl.getTimeRemaining());
        verify(mockClock);
    }
View Full Code Here

    }

    @Test
    public void hasZeroTimeRemainingIfElapsed() {
        expect(mockClock.getGranularity()).andReturn(1L).anyTimes();
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(4L,5L));
        expect(mockClock.getNanoTime()).andReturn(new DiscreteInterval(1005L,1006L)).anyTimes();
        replay(mockClock);
        impl.set(1000L,100L);
        impl.start();
        assertEquals(new DiscreteInterval(0L,0L), impl.getTimeRemaining());
        verify(mockClock);
    }
View Full Code Here

TOP

Related Classes of org.fishwife.jrugged.interval.DiscreteInterval

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.