Package com.mdimension.jchronic

Source Code of com.mdimension.jchronic.RepeaterMonthNameTest

package com.mdimension.jchronic;

import java.util.Calendar;

import junit.framework.TestCase;

import com.mdimension.jchronic.repeaters.RepeaterMonthName;
import com.mdimension.jchronic.tags.Pointer;
import com.mdimension.jchronic.utils.Span;
import com.mdimension.jchronic.utils.Time;

public class RepeaterMonthNameTest extends TestCase {
  private Calendar _now;

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    _now = Time.construct(2006, 8, 16, 14, 0, 0, 0);
  }

  public void testNext() {
    RepeaterMonthName mays = new RepeaterMonthName(RepeaterMonthName.MonthName.MAY);
    mays.setStart(_now);
   
    Span nextMay = mays.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2007, 5), nextMay.getBeginCalendar());
    assertEquals(Time.construct(2007, 6), nextMay.getEndCalendar());

    Span nextNextMay = mays.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2008, 5), nextNextMay.getBeginCalendar());
    assertEquals(Time.construct(2008, 6), nextNextMay.getEndCalendar());

    RepeaterMonthName decembers = new RepeaterMonthName(RepeaterMonthName.MonthName.DECEMBER);
    decembers.setStart(_now);
   
    Span nextDecember = decembers.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 12), nextDecember.getBeginCalendar());
    assertEquals(Time.construct(2007, 1), nextDecember.getEndCalendar());

    mays = new RepeaterMonthName(RepeaterMonthName.MonthName.MAY);
    mays.setStart(_now);
   
    assertEquals(Time.construct(2006, 5), mays.nextSpan(Pointer.PointerType.PAST).getBeginCalendar());
    assertEquals(Time.construct(2005, 5), mays.nextSpan(Pointer.PointerType.PAST).getBeginCalendar());
  }

  public void testThis() {
    RepeaterMonthName octobers = new RepeaterMonthName(RepeaterMonthName.MonthName.MAY);
    octobers.setStart(_now);
   
    Span nextMay = octobers.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2007, 5), nextMay.getBeginCalendar());
    assertEquals(Time.construct(2007, 6), nextMay.getEndCalendar());

    Span nextNextMay = octobers.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2008, 5), nextNextMay.getBeginCalendar());
    assertEquals(Time.construct(2008, 6), nextNextMay.getEndCalendar());
  }
}
TOP

Related Classes of com.mdimension.jchronic.RepeaterMonthNameTest

TOP
Copyright © 2018 www.massapi.com. 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.