001package edu.pdx.cs.joy.family;
002
003import org.junit.jupiter.api.Test;
004
005import static org.junit.jupiter.api.Assertions.fail;
006
007/**
008 * This class tests the functionality of the <code>Marriage</code>
009 * class.
010 */
011public class MarriageTest extends FamilyTestCase {
012
013  @Test
014  public void testMarriage() {
015    Person husband = new Person(1, Person.MALE);
016    Person wife = new Person(2, Person.FEMALE);
017    Marriage m = new Marriage(husband, wife);
018    assertEquals(husband, m.getHusband());
019    assertEquals(wife, m.getWife());
020  }
021
022  @Test
023  public void testMarriageHusbandNotMale() {
024    Person husband = new Person(1, Person.FEMALE);
025    Person wife = new Person(2, Person.FEMALE);
026    try {
027      new Marriage(husband, wife);
028      fail("Should have thrown an IllegalArgumentException");
029
030    } catch (IllegalArgumentException ex) {
031      // pass ...
032    }
033  }
034
035  @Test
036  public void testMarriageWifeNotFemale() {
037    Person husband = new Person(1, Person.MALE);
038    Person wife = new Person(2, Person.MALE);
039    try {
040      new Marriage(husband, wife);
041      fail("Should have thrown an IllegalArgumentException");
042
043    } catch (IllegalArgumentException ex) {
044      // pass ...
045    }
046  }
047
048}