//Created by Bill Meehan

package com.example.test;
import com.example.model.*;
import junit.framework.*;
import java.lang.*;
import java.util.*;

public class TimeIntervalTest extends TestCase {

    public TimeIntervalTest(String name) {
	super(name);
    }
   
    public void testGetStart() {
	TimeInterval ti = new TimeInterval(830, 1030);
	int expected = 830;

	Assert.assertTrue(ti.getStart() == expected);
    }

    public void testGetEnd() {
	TimeInterval ti1 = new TimeInterval(830, 1030);
	int expected = 1030;

	Assert.assertTrue(ti1.getEnd() == expected);
    }

    public void testGetStartTimeString() {
	TimeInterval ti1 = new TimeInterval(800, 1030);
	TimeInterval ti2 = new TimeInterval(1750, 1840);
	String expected1 = "8:00 AM";
	String expected2 = "5:50 PM";
	String test1 = ti1.getStartTimeString();
	String test2 = ti2.getStartTimeString();
	
	Assert.assertTrue(expected1.equals(test1));
	Assert.assertTrue(expected2.equals(test2));
    }

    public void testGetEndTimeString() {
	TimeInterval ti1 = new TimeInterval(800, 1030);
	TimeInterval ti2 = new TimeInterval(1750, 1840);
	String expected1 = "10:30 AM";
	String expected2 = "6:40 PM";
	String test1 = ti1.getEndTimeString();
	String test2 = ti2.getEndTimeString();
	
	Assert.assertTrue(expected1.equals(test1));
	Assert.assertTrue(expected2.equals(test2));
    }

    public void testIsBefore() {
	TimeInterval ti1 = new TimeInterval(930, 1100);
	TimeInterval ti2 = new TimeInterval(1200, 130);

	Assert.assertTrue(ti1.isBefore(ti2));
    }
	
    public void testIsAfter() {
     	TimeInterval ti1 = new TimeInterval(1630, 1800);
	TimeInterval ti2 = new TimeInterval(1220, 1300);

	Assert.assertTrue(ti1.isAfter(ti2));
    }
 
    public void testIsDuring() {
	TimeInterval ti1 = new TimeInterval(1010, 1200);
	TimeInterval ti2 = new TimeInterval(930, 1330);

	Assert.assertTrue(ti1.isDuring(ti2));
    }

    public void testIsStartOut() {
	TimeInterval ti1 = new TimeInterval(800, 1100);
	TimeInterval ti2 = new TimeInterval(1000, 1200);
	
	Assert.assertTrue(ti1.isStartOut(ti2));
    }

    public void testIsEndOut() {
	TimeInterval ti1 = new TimeInterval(930, 1600);
	TimeInterval ti2 = new TimeInterval(800, 1200);
	
	Assert.assertTrue(ti1.isEndOut(ti2));
    }

    public void testDifference() {
	TimeInterval ti1 = new TimeInterval(800, 800);
	TimeInterval ti2 = new TimeInterval(930, 1640);
	int expected1 = 0;
	int expected2 = 710;
	int test1 = ti1.difference();
	int test2 = ti2.difference();

	Assert.assertTrue(test1 == expected1);
	Assert.assertTrue(test2 == expected2);
    }
}
