package seedu.ezdo.model.task;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import seedu.ezdo.model.todo.Recur;
//@@author A0139177W
public class RecurTest {

    @Test
    public void isValidRecur() {
        // invalid recur interval
        assertFalse(Recur.isValidRecur(" "));
        assertFalse(Recur.isValidRecur("everyday"));
        assertFalse(Recur.isValidRecur("week"));
        assertFalse(Recur.isValidRecur("month"));
        assertFalse(Recur.isValidRecur("year"));

        // valid recur interval
        assertTrue(Recur.isValidRecur(""));
        assertTrue(Recur.isValidRecur("daily"));
        assertTrue(Recur.isValidRecur("weekly"));
        assertTrue(Recur.isValidRecur("monthly"));
        assertTrue(Recur.isValidRecur("yearly"));
    }

    @Test
    public void isRecur() throws Exception {
        Recur noRecur = new Recur("");
        Recur validRecur = new Recur("monthly");
        assertFalse(noRecur.isRecur());
        assertTrue(validRecur.isRecur());
    }

    @Test
    public void printToString() throws Exception {
        Recur testRecur = new Recur("daily");
        assertEquals(testRecur.toString(), "daily");
    }

    @Test
    public void testEquals() throws Exception {
        Recur testRecur = new Recur("daily");
        Recur testRecur2 = testRecur;
        assertTrue(testRecur.equals(testRecur2));
    }

    @Test
    public void hashCode_equals() throws Exception {
        Recur testRecur = new Recur("daily");
        assertEquals(testRecur.hashCode(), (new Recur("daily")).hashCode());
    }
}


@@ -179,14 +179,202 @@
 nit.
-Test;%0A
+Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0A%0Aimport mockit.Expectations;%0Aimport seedu.ezdo.commons.exceptions.IllegalValueException;%0Aimport seedu.ezdo.model.todo.Name;
 %0Aimp
@@ -406,16 +406,17 @@
 .Recur;%0A
+%0A
 //@@auth
@@ -427,12 +427,12 @@
 0139
-177W
+248X
 %0Apub
@@ -454,16 +454,113 @@
 Test %7B%0A%0A
+    @Rule%0A    public ExpectedException thrown = ExpectedException.none();%0A  //@@author A0139177W%0A
     @Tes
@@ -1949,11 +1949,353 @@
 ;%0A    %7D%0A
-%7D%0A%0A
+%0A    //@@author A0139248X%0A    @Test%0A    public void constructor_isValidRecur_throwsIVE() throws IllegalValueException %7B%0A        thrown.expect(IllegalValueException.class);%0A        new Expectations(Recur.class) %7B%0A            %7B%0A                Recur.isValidRecur(%22test%22); result = false;%0A            %7D%0A        %7D;%0A        new Recur(%22test%22);%0A    %7D%0A%7D

Add unit test for Recur