/*
 * Copyright © 2015 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;

@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.DEFAULT_MESSAGE, areaPicker.getText());
    }

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

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

        assertEquals(AreaPicker.DEFAULT_MESSAGE, 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());
    }
}
@@ -13,14 +13,16 @@
 ght 
-%C2%A9
+(c)
  201
-5
+6
  NEC
@@ -649,16 +649,19 @@
 icense.%0A
+ *%0A
  */%0A%0Apac
@@ -1037,16 +1037,59 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertNull;
 %0A%0A@Ignor
@@ -1191,17 +1191,16 @@
 Test %7B%0A%0A
-%0A
     priv
@@ -1554,38 +1554,35 @@
 uals(AreaPicker.
-DEFAUL
+HIN
 T_MESSAGE, areaP
@@ -1568,32 +1568,74 @@
 r.HINT_MESSAGE, 
+areaPicker.getHint());%0A        assertNull(
 areaPicker.getTe
@@ -1846,43 +1846,13 @@
 sert
-Equals(AreaPicker.DEFAULT_MESSAGE, 
+Null(
 area
@@ -2280,9 +2280,10 @@
 ;%0A    %7D%0A
-
 %7D
+%0A

Fix AreaPickerTest