// ChapterTest.java  P. Conrad, for CISC370, 06/18/2007
// Compare Recipe 4.1 from Java Extreme Programming Cookbook, p. 60

import junit.framework.TestCase;

/**
 * Unit tests for the {@link Chapter} class.
 * @author Phill Conrad
 */


public class ChapterTest extends TestCase {

    /**
     * A unit test to verify that we can get the chapter name
     */

    public void testGetName() {
	Chapter c = new Chapter("Chapter 1","My First Chapter");	
	assertEquals("Chapter 1",c.getName());
    }

    /**
     * A unit test to verify that we can get the chapter title
     */

    public void testGetTitle() {
	Chapter c = new Chapter("Chapter 1","My First Chapter");	
	assertEquals("My First Chapter",c.getTitle());
    }

    public void testAddSection() {

	Section s1 = new Section("Section 1.1",
				 "My First Section", 
				 "2",
				 "hfjava2-CHP-1-SECT-1");

	Section s2 = new Section("Section 1.2",
				 "The Next Section", 
				 "6",
				 "hfjava2-CHP-1-SECT-2");

	Chapter c = new Chapter("Chapter 1","My First Chapter");	
	c.add(s1);
	c.add(s2);

	assertEquals(2, c.getNumSections());

	assertEquals("Section 1.1",c.getSection(0).getName());
	assertEquals("My First Section",c.getSection(0).getTitle());
	assertEquals("2",c.getSection(0).getPage());
	assertEquals("hfjava2-CHP-1-SECT-1",c.getSection(0).getSafari());

	assertEquals("Section 1.2",c.getSection(1).getName());
	assertEquals("The Next Section",c.getSection(1).getTitle());
	assertEquals("6",c.getSection(1).getPage());
	assertEquals("hfjava2-CHP-1-SECT-2",c.getSection(1).getSafari());

    }

} // class
