package com.thebluealliance.androidclient.helpers;

import com.thebluealliance.androidclient.types.MatchType;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static org.junit.Assert.assertEquals;

@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class MatchTypeTest {

    @Test
    public void testNextPlayOrder() {
        assertEquals(MatchType.QUAL.next(), MatchType.QUARTER);
        assertEquals(MatchType.QUARTER.next(), MatchType.SEMI);
        assertEquals(MatchType.SEMI.next(), MatchType.FINAL);
        assertEquals(MatchType.FINAL.next(), null);
    }

    @Test
    public void testPreviousPlayOrder() {
        assertEquals(MatchType.QUAL.previous(), null);
        assertEquals(MatchType.QUARTER.previous(), MatchType.QUAL);
        assertEquals(MatchType.SEMI.previous(), MatchType.QUARTER);
        assertEquals(MatchType.FINAL.previous(), MatchType.SEMI);
    }

    @Test
    public void testTypeFromShortStr() {
        assertEquals(MatchType.fromShortType("qm"), MatchType.QUAL);
        assertEquals(MatchType.fromShortType("qf"), MatchType.QUARTER);
        assertEquals(MatchType.fromShortType("sf"), MatchType.SEMI);
        assertEquals(MatchType.fromShortType("f"), MatchType.FINAL);

        //TODO(#430) proper eighth finals support eventually
        assertEquals(MatchType.fromShortType("ef"), MatchType.QUARTER);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testInvalidShortStr() {
        MatchType.fromShortType("meow");
    }

    @Test
    public void testTypeFromKey() {
        assertEquals(MatchType.fromKey("2015cthar_qm1"), MatchType.QUAL);
        assertEquals(MatchType.fromKey("2015cthar_qf1m1"), MatchType.QUARTER);
        assertEquals(MatchType.fromKey("2015cthar_sf2m2"), MatchType.SEMI);
        assertEquals(MatchType.fromKey("2015cthar_f1m3"), MatchType.FINAL);
        assertEquals(MatchType.fromKey("21rwewfjsd"), MatchType.NONE);
    }
}

@@ -478,32 +478,93 @@
 ype.QUAL.next(),
+ MatchType.OCTO);%0A        assertEquals(MatchType.OCTO.next(),
  MatchType.QUART
@@ -560,32 +560,32 @@
 hType.QUARTER);%0A
-
         assertEq
@@ -856,24 +856,89 @@
 s(), null);%0A
+        assertEquals(MatchType.OCTO.previous(), MatchType.QUAL);%0A
         asse
@@ -978,36 +978,36 @@
 us(), MatchType.
-QUAL
+OCTO
 );%0A        asser
@@ -1469,69 +1469,8 @@
 );%0A%0A
-        //TODO(#430) proper eighth finals support eventually%0A
     
@@ -1523,31 +1523,28 @@
 , MatchType.
-QUARTER
+OCTO
 );%0A    %7D%0A%0A  
@@ -1949,32 +1949,32 @@
 atchType.SEMI);%0A
-
         assertEq
@@ -2025,32 +2025,109 @@
 tchType.FINAL);%0A
+        assertEquals(MatchType.fromKey(%222015micmp_ef1m12%22), MatchType.OCTO);%0A
         assertEq

Update tests for octofinals match type