001package edu.pdx.cs.joy.junit;
002
003import org.junit.jupiter.api.Test;
004import static org.junit.jupiter.api.Assertions.fail;
005import static org.junit.jupiter.api.Assertions.assertEquals;
006
007/**
008 * This class tests the functionality of the <code>Course</code> class.
009 */
010public class CourseTest {
011
012  @Test
013  public void testGoodCourse() {
014    new Course("Computer Science", 410, 4);
015  }
016
017  @Test
018  public void testCourseNumberLessThan100() {
019    try {
020      new Course("Computer Science", 17, 4);
021      fail("Should have thrown an IllegalArgumentException");
022
023    } catch (IllegalArgumentException ex) {
024      // pass...
025    }
026  }
027
028  @Test
029  public void testCreditLessThanZero() {
030    try {
031      new Course("Computer Science", 410, -3);
032      fail("Should have thrown an IllegalArgumentException");
033
034    } catch (IllegalArgumentException ex) {
035      // pass...
036    }
037  }
038
039  @Test
040  public void testGetCredits() {
041    int credits = 4;
042    Course c = new Course("Computer Science", 410, credits);
043    assertEquals(credits, c.getCredits());
044  }
045  
046}