package treehou.se.habit;

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

import treehou.se.habit.core.db.ItemDB;
import treehou.se.habit.core.db.StateDescription;

@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, packageName = "treehou.se.habit", sdk = 21)
public class ItemTest {

    @Test
    public void check_name_is_correct() throws Exception {

        ItemDB item = new ItemDB();
        item.setName("Device");

        if(BuildConfig.DEBUG && !item.getName().equals("Device")) {
            throw new AssertionError();
        }
    }

    @Test
    public void check_formated_name_is_correct() throws Exception {

        ItemDB item = new ItemDB();
        item.setName("Device [%.2f]");

        StateDescription stateDescription = new StateDescription();
        stateDescription.setPattern("%.2f");
        item.setStateDescription(stateDescription);

        item.setState("12.2");

        String printableName = item.printableName();
        if(BuildConfig.DEBUG && !item.printableName().equals("Device 12.20")) {
            throw new AssertionError();
        }
    }
}

@@ -719,19 +719,20 @@
 ormated_
-nam
+stat
 e_is_cor
@@ -797,47 +797,8 @@
 B();
-%0A        item.setName(%22Device %5B%25.2f%5D%22);
 %0A%0A  
@@ -1017,19 +1017,20 @@
 rintable
-Nam
+Stat
 e = item
@@ -1030,28 +1030,31 @@
  = item.
-printableNam
+getFormatedValu
 e();%0A   
@@ -1083,21 +1083,16 @@
 BUG && !
-item.
 printabl
@@ -1092,22 +1092,21 @@
 rintable
-Name()
+State
 .equals(
@@ -1110,18 +1110,11 @@
 ls(%22
-Device 
 12
-.
+,
 20%22)

Update test for item