더북(TheBook)

iloveyouboss_11/test/iloveyouboss/ProfileTest.java

public class ProfileTest {
    private Profile profile;
    private BooleanQuestion question;
    private Criteria criteria;

<span class="brown">@Before</span>
<span class="brown">public void create() {</span>
    <span class="brown">profile = new Profile("Bull Hockey, Inc.");</span>
    <span class="brown">question = new BooleanQuestion(1, "Got bonuses?");</span>
    <span class="brown">criteria = new Criteria();</span>
<span class="brown">}</span>

@Test
public void matchAnswersFalseWhenMustMatchCriteriaNotMet() {
    Answer profileAnswer = new Answer(question, Bool.FALSE);
    profile.add(profileAnswer);
    Answer criteriaAnswer = new Answer(question, Bool.TRUE);
    Criterion criterion = new Criterion(criteriaAnswer, 
                                        Weight.MustMatch);
    criteria.add(criterion);

    boolean matches = profile.matches(criteria);

    assertFalse(matches);
}

@Test
public void matchAnswersTrueForAnyDontCareCriteria() {
    Answer profileAnswer = new Answer(question, Bool.FALSE);
    profile.add(profileAnswer);
    Answer criteriaAnswer = new Answer(question, Bool.TRUE);
    Criterion criterion = new Criterion(criteriaAnswer, 
                                        Weight.DontCare);
    criteria.add(criterion);

    boolean matches = profile.matches(criteria);

    assertTrue(matches);
}

}


신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.