/*
 * Copyright (c) 2016 NECTEC
 *   National Electronics and Computer Technology Center, Thailand
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package th.or.nectec.thai.widget.unit;

import android.app.Activity;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import th.or.nectec.thai.unit.Area;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

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

    private AreaPicker areaPicker;

    @Before
    public void setUp() throws Exception {
        areaPicker = new AreaPicker(mockActivity());
    }

    private Activity mockActivity() {
        return Robolectric.buildActivity(Activity.class).create().get();
    }

    @Test
    public void testShowDefaultMessage() throws Exception {
        assertEquals(AreaPicker.HINT_MESSAGE, areaPicker.getHint());
        assertNull(areaPicker.getText());
    }

    @Test
    public void testResetArea() throws Exception {
        areaPicker.setArea(Area.fromRaiNganSqaureWa(2, 0, 30));

        areaPicker.setArea(Area.fromSquareMeter(0));

        assertNull(areaPicker.getText());
    }

    @Test
    public void testShowAreaRaiNganSquareWa() throws Exception {
        areaPicker.setArea(Area.fromRaiNganSqaureWa(3, 3, 40));

        assertEquals("3 ไร่ 3 งาน 40 ตารางวา", areaPicker.getText());
    }

    @Test
    public void testShowOnlyRai() throws Exception {
        areaPicker.setArea(Area.fromRaiNganSqaureWa(2, 0, 0));

        assertEquals("2 ไร่", areaPicker.getText());
    }
}

@@ -755,33 +755,8 @@
 re;%0A
-import org.junit.Ignore;%0A
 impo
@@ -869,32 +869,38 @@
 tric.Robolectric
+Gradle
 TestRunner;%0Aimpo
@@ -972,16 +972,61 @@
 it.Area;
+%0Aimport th.or.nectec.thai.widget.BuildConfig;
 %0A%0Aimport
@@ -1068,59 +1068,8 @@
 ls;%0A
-import static org.junit.Assert.assertNull;%0A%0A@Ignore
 %0A@Ru
@@ -1085,16 +1085,22 @@
 olectric
+Gradle
 TestRunn
@@ -1121,30 +1121,90 @@
 fig(
-manifest = Config.NONE
+constants = BuildConfig.class, sdk = 21, manifest = %22src/main/AndroidManifest.xml%22
 )%0Apu
@@ -1646,37 +1646,43 @@
 ;%0A        assert
-Null(
+Equals(%22%22, 
 areaPicker.getTe
@@ -1893,13 +1893,19 @@
 sert
-Null(
+Equals(%22%22, 
 area

Fix AreaPickerTest