package hiteware.com.halfwaythere;

import android.widget.TextView;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;

/**
 * Created by jasonhite on 4/29/15.
 */

@RunWith(CustomRobolectricRunner.class)
@Config(constants = BuildConfig.class)
public class SensorIntegrationTest
{
    public MainActivity CreatedActivity;
    public TestInjectableApplication application;

    StepSensorChange stepSensorChange;

    @Before
    public void setUp()
    {
        application = (TestInjectableApplication) RuntimeEnvironment.application;
        CreatedActivity = Robolectric.buildActivity(MainActivity.class).create().postResume().get();
        stepSensorChange = application.stepSensorChangeModule.provideStepSensorChange();
    }

    @Test
    public void whenAStepCounterValueIsInjectedTheDisplayIsUpdated()
    {
        stepSensorChange.onSensorChanged(SensorValue.CreateSensorEvent(24));
        assertThat(((TextView) CreatedActivity.findViewById(R.id.step_value)).getText().toString(), equalTo("23"));
    }
}

@@ -1139,17 +1139,17 @@
 rEvent(2
-4
+3
 ));%0A    

Revert "Intentional fail to make Jenkins Fail if it is checking tests"