package net.woodyfolsom.cs6601.p2;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.Is.*;

import java.io.File;

import org.junit.Test;

public class SurveyReaderTest {

	@Test
	public void testReadLongSurveyDataset() {
		Survey survey = SurveyReader.readSurvey(new File("data/long_survey.xml"));
		assertNotNull(survey);
		
		assertThat(survey.getDishCount(), equalTo(10));
		assertThat(survey.getDinerCount(), equalTo(4));
		
		assertThat(survey.isCategory(0,"vegetarian"), is(false));
		assertThat(survey.isCategory(0,"allergic-nuts"), is(false));
		
		assertThat(survey.isCategory(1,"vegetarian"), is(true));
		assertThat(survey.isCategory(1,"allergic-nuts"), is(false));
		
		assertThat(survey.isCategory(2,"vegan"), is(false));
		assertThat(survey.isCategory(2,"allergic-nuts"), is(true));
		
		assertThat(survey.isDiner("vegetarian"), is(true));
		assertThat(survey.isDiner("allergic-nuts"), is(true));
		assertThat(survey.isDiner("rastafarian"), is(false));
	}
	
	@Test
	public void testReadMediumSurveyDataset() {
		Survey survey = SurveyReader.readSurvey(new File("data/medium_survey.xml"));
		assertNotNull(survey);
		
		assertThat(survey.getDinerCount(), equalTo(2));
		
		Diner diner = survey.getDiner(0);
		assertThat(diner.isCategory(0), is(false));
		diner = survey.getDiner(1);
		assertThat(diner.isCategory(0), is(true));
	}
}
