|
|
@ -17,30 +17,24 @@
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
package org.isoron.uhabits.unit.commands;
|
|
|
|
package org.isoron.uhabits.commands;
|
|
|
|
|
|
|
|
|
|
|
|
import android.support.test.runner.AndroidJUnit4;
|
|
|
|
import org.isoron.uhabits.*;
|
|
|
|
import android.test.suitebuilder.annotation.SmallTest;
|
|
|
|
import org.isoron.uhabits.models.*;
|
|
|
|
|
|
|
|
import org.junit.*;
|
|
|
|
|
|
|
|
|
|
|
|
import org.isoron.uhabits.BaseAndroidTest;
|
|
|
|
import java.util.*;
|
|
|
|
import org.isoron.uhabits.commands.ChangeHabitColorCommand;
|
|
|
|
|
|
|
|
import org.isoron.uhabits.models.Habit;
|
|
|
|
|
|
|
|
import org.junit.Before;
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import static org.hamcrest.CoreMatchers.*;
|
|
|
|
|
|
|
|
import static org.hamcrest.MatcherAssert.*;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.MatcherAssert.assertThat;
|
|
|
|
public class ChangeHabitColorCommandTest extends BaseUnitTest
|
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RunWith(AndroidJUnit4.class)
|
|
|
|
|
|
|
|
@SmallTest
|
|
|
|
|
|
|
|
public class ChangeHabitColorCommandTest extends BaseAndroidTest
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private ChangeHabitColorCommand command;
|
|
|
|
private ChangeHabitColorCommand command;
|
|
|
|
|
|
|
|
|
|
|
|
private LinkedList<Habit> habits;
|
|
|
|
private LinkedList<Habit> habits;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Before
|
|
|
|
@Before
|
|
|
|
public void setUp()
|
|
|
|
public void setUp()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -48,7 +42,7 @@ public class ChangeHabitColorCommandTest extends BaseAndroidTest
|
|
|
|
|
|
|
|
|
|
|
|
habits = new LinkedList<>();
|
|
|
|
habits = new LinkedList<>();
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 3; i ++)
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Habit habit = fixtures.createShortHabit();
|
|
|
|
Habit habit = fixtures.createShortHabit();
|
|
|
|
habit.setColor(i + 1);
|
|
|
|
habit.setColor(i + 1);
|
|
|
@ -73,16 +67,16 @@ public class ChangeHabitColorCommandTest extends BaseAndroidTest
|
|
|
|
checkNewColors();
|
|
|
|
checkNewColors();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void checkOriginalColors()
|
|
|
|
private void checkNewColors()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int k = 0;
|
|
|
|
for (Habit h : habits)
|
|
|
|
for(Habit h : habits)
|
|
|
|
assertThat(h.getColor(), equalTo(0));
|
|
|
|
assertThat(h.getColor(), equalTo(++k));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void checkNewColors()
|
|
|
|
private void checkOriginalColors()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(Habit h : habits)
|
|
|
|
int k = 0;
|
|
|
|
assertThat(h.getColor(), equalTo(0));
|
|
|
|
for (Habit h : habits)
|
|
|
|
|
|
|
|
assertThat(h.getColor(), equalTo(++k));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|