package com.philisense.rdgo.viewModel;

import android.databinding.DataBindingUtil;

import com.philisense.rdgo.BuildConfig;
import com.philisense.rdgo.R;
import com.philisense.rdgo.bean.OError;
import com.philisense.rdgo.bean.response.BoxInfoBean;
import com.philisense.rdgo.bean.response.PileInfoBean;
import com.philisense.rdgo.http.RequestImpl;
import com.philisense.rdgo.http.cache.ACache;
import com.philisense.rdgo.ui.putOut.PutOutOrderActivity;
import com.philisense.rdgo.ui.user.LoginActivity;
import com.philisense.rdgo.util.Constant;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmQuery;
import io.realm.RealmResults;
import io.realm.internal.RealmCore;
import io.realm.log.RealmLog;

import static junit.framework.Assert.assertEquals;

/**
 * Created by shaop on 2017/12/18.
 */
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21)
@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"})
@SuppressStaticInitializationFor("io.realm.internal.Util")
@PrepareForTest({Realm.class, RealmConfiguration.class, RealmQuery.class, RealmResults.class, RealmCore.class, RealmLog.class})
public class PutOutOrderViewModelTest {

    private PutOutOrderViewModel viewModel;

    @Before
    public void setUp() {
        viewModel = new PutOutOrderViewModel(RuntimeEnvironment.application);
        ACache.get(RuntimeEnvironment.application).put(Constant.ACCESSTOKEN,"eyJhbGciOiJIUzI1NiJ9.MTUxMzU3NzU3MDYyNw.H1UjUwyDhRavvWM0w0PhKWtd6sHSLbX5cPjYfTs35dI");
    }

    /**
     * 获取箱信息
     */
    @Test
    public void getBoxInfo() {
        viewModel.getBoxInfo("492054.7239859628", new RequestImpl<BoxInfoBean>() {
            @Override
            public void loadSuccess(BoxInfoBean bean) {
                assertEquals(bean.getSuccess(),0);
            }

            @Override
            public void loadFailed(OError error) {
                assertEquals(true,false);
            }
        });
    }

    /**
     * 获取跺信息
     */
    @Test
    public void getPileInfo() {
        viewModel.getPileInfo("314886.0801337338",new RequestImpl<PileInfoBean>() {
            @Override
            public void loadSuccess(PileInfoBean bean) {
                assertEquals(bean.getSuccess(),0);
            }

            @Override
            public void loadFailed(OError error) {
                assertEquals(true,false);
            }
        });
    }



}
