package hk.reality.stock.service.fetcher;

import junit.framework.TestCase;

import org.apache.commons.lang.StringUtils;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class Money18QuoteFetcherTest extends TestCase {

    protected void setUp() throws Exception {
        super.setUp();
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public void testJson() throws JSONException {
        String jsonSrc = "M18.r_00005 = {    ltt: '2009/10/07 16:00',    np: '87.450',    iep: '0.000',    iev: '00000000000',    ltp: '87.600',    vol: '00025255927',    tvr: '02204863352',    dyh: '87.700',    dyl: '86.850'};";
        int pos = jsonSrc.indexOf('{');
        String result = StringUtils.substring(jsonSrc, pos);
        JSONObject json = new JSONObject(result);
        
        Log.d("TEST", json.toString(2));

    }

}

@@ -36,16 +36,90 @@
 tcher;%0A%0A
+import hk.reality.stock.model.StockDetail;%0Aimport junit.framework.Assert;%0A
 import j
@@ -978,10 +978,954 @@
 %0A    %7D%0A%0A
+    public void testGetStockNormal() %7B%0A        testStock(%2200005%22);%0A        testStock(%2203328%22);%0A    %7D%0A    %0A    public void testGetStockDerivatives() %7B%0A        testStock(%2217032%22);%0A    %7D%0A    %0A    private void testStock(String quote) %7B%0A        QuoteFetcher fetcher = getFetcher();%0A        StockDetail detail = fetcher.fetch(quote);%0A        Assert.assertNotNull(detail);%0A        Assert.assertNotNull(detail.getQuote());%0A        Assert.assertNotNull(detail.getSourceUrl());%0A        Assert.assertNotNull(detail.getVolume());%0A        Assert.assertNotNull(detail.getChangePrice());%0A        Assert.assertNotNull(detail.getChangePricePercent());%0A        Assert.assertNotNull(detail.getDayHigh());%0A        Assert.assertNotNull(detail.getDayLow());%0A        Assert.assertNotNull(detail.getPrice());%0A        Assert.assertNotNull(detail.getUpdatedAt());%0A    %7D%0A    %0A    protected QuoteFetcher getFetcher() %7B%0A        return new Money18QuoteFetcher();%0A    %7D%0A    %0A
 %7D%0A

add test for fetcher