コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void setCurrentTimeShouldFreezeTime() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void setCurrentTimeShouldFreezeTime()
        {
            long     duration = TWO_DAYS;
            DateTime target   = new DateTime((DateTime.Now).Ticks + duration);

            ClockUtil.CurrentTime = target;

            Thread.Sleep(1100L);

            assertThat(ClockUtil.now()).isCloseTo(target, ONE_SECOND);
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void offsetShouldTravelInTime() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void offsetShouldTravelInTime()
        {
            long     duration = TWO_DAYS;
            DateTime target   = new DateTime((DateTime.Now).Ticks + duration);

            ClockUtil.offset(duration);

            Thread.Sleep(1100L);

            assertThat(ClockUtil.now()).isCloseTo(target, TWO_SECONDS);
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void resetClockShouldResetToCurrentTime()
        public virtual void resetClockShouldResetToCurrentTime()
        {
            long     duration = TWO_DAYS;
            DateTime target   = new DateTime((DateTime.Now).Ticks + duration);

            ClockUtil.offset(duration);

            assertThat(ClockUtil.now()).isCloseTo(target, ONE_SECOND);

            assertThat(ClockUtil.resetClock()).isCloseTo(DateTime.Now, ONE_SECOND);
            assertThat(ClockUtil.CurrentTime).isCloseTo(DateTime.Now, ONE_SECOND);
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void timeShouldFreezeWithSetCurrentTime() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void timeShouldFreezeWithSetCurrentTime()
        {
            DateTime now      = DateTime.Now;
            long     duration = TWO_DAYS;
            DateTime target   = new DateTime(now.Ticks + duration);

            ClockUtil.CurrentTime = target;

            Thread.Sleep(FIVE_SECONDS);

            assertThat(ClockUtil.now()).isCloseTo(target, ONE_SECOND);
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void timeShouldMoveOnAfterTravel() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void timeShouldMoveOnAfterTravel()
        {
            DateTime now      = DateTime.Now;
            long     duration = TWO_DAYS;
            DateTime target   = new DateTime(now.Ticks + duration);

            ClockUtil.offset(duration);

            assertThat(ClockUtil.now()).isCloseTo(target, ONE_SECOND);

            Thread.Sleep(FIVE_SECONDS);

            assertThat(ClockUtil.now()).isCloseTo(new DateTime(target.Ticks + FIVE_SECONDS), ONE_SECOND);
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void getCurrentTimeShouldReturnSameValueAsNow()
        public virtual void getCurrentTimeShouldReturnSameValueAsNow()
        {
            assertThat(ClockUtil.CurrentTime).isCloseTo(ClockUtil.now(), ONE_SECOND);
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void nowShouldReturnCurrentTime()
        public virtual void nowShouldReturnCurrentTime()
        {
            assertThat(ClockUtil.now()).isCloseTo(DateTime.Now, ONE_SECOND);
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @AfterClass public static void resetClock()
        public static void resetClock()
        {
            ClockUtil.reset();
        }
コード例 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void setUp()
        {
            ClockUtil.reset();
        }