forked from github/wulkanowy-mirror
Migrate to greenDAO (#23)
* Migration of database operation to greenDAO * Disable crashlitics for debug builds * Remove unused drawable * Fix crash when user have one grade
This commit is contained in:

committed by
Mikołaj Pich

parent
9b4c406934
commit
690b730494
@ -0,0 +1,80 @@
|
||||
package io.github.wulkanowy.dao;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.dao.entities.Grade;
|
||||
|
||||
|
||||
public class EntitiesCompareTest {
|
||||
|
||||
private List<Grade> newList = new ArrayList<>();
|
||||
|
||||
private List<Grade> oldList = new ArrayList<>();
|
||||
|
||||
private Grade grade1;
|
||||
|
||||
private Grade grade2;
|
||||
|
||||
@Before
|
||||
public void prepareObjects() {
|
||||
grade1 = new Grade()
|
||||
.setSubject("Matematyka")
|
||||
.setValue("6")
|
||||
.setColor("FFFFFF")
|
||||
.setSymbol("S")
|
||||
.setDescription("Lorem ipsum")
|
||||
.setWeight("10")
|
||||
.setDate("01.01.2017")
|
||||
.setTeacher("Andrzej")
|
||||
.setSemester("777");
|
||||
|
||||
grade2 = new Grade()
|
||||
.setSubject("Religia")
|
||||
.setValue("6")
|
||||
.setColor("FFFFFF")
|
||||
.setSymbol("S")
|
||||
.setDescription("Wolna wola")
|
||||
.setWeight("10")
|
||||
.setDate("01.01.2017")
|
||||
.setTeacher("Andrzej")
|
||||
.setSemester("777");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareNewGradePositive() {
|
||||
|
||||
newList.add(grade1);
|
||||
|
||||
List<Grade> updatedList = EntitiesCompare.compareGradeList(newList, oldList);
|
||||
|
||||
Assert.assertEquals(true, (updatedList.get(0)).getIsNew());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareNewGradeNegative() {
|
||||
|
||||
newList.add(grade1);
|
||||
newList.add(grade1);
|
||||
oldList.add(grade1);
|
||||
oldList.add(grade2);
|
||||
|
||||
List<Grade> updatedList = EntitiesCompare.compareGradeList(newList, oldList);
|
||||
|
||||
Assert.assertEquals(false, (updatedList.get(0)).getIsNew());
|
||||
Assert.assertEquals(false, (updatedList.get(1)).getIsNew());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareEmptyGradeList() {
|
||||
|
||||
List<Grade> updatedList = EntitiesCompare.compareGradeList(newList, oldList);
|
||||
|
||||
Assert.assertEquals(new ArrayList<>(), updatedList);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package io.github.wulkanowy.dao.entities;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import io.github.wulkanowy.R;
|
||||
|
||||
public class GradeTest {
|
||||
|
||||
@Test
|
||||
public void getValueColorTest() {
|
||||
Assert.assertEquals(R.color.six_grade, new Grade().setValue("-6").getValueColor());
|
||||
Assert.assertEquals(R.color.five_grade, new Grade().setValue("--5").getValueColor());
|
||||
Assert.assertEquals(R.color.four_grade, new Grade().setValue("=4").getValueColor());
|
||||
Assert.assertEquals(R.color.three_grade, new Grade().setValue("3-").getValueColor());
|
||||
Assert.assertEquals(R.color.two_grade, new Grade().setValue("2--").getValueColor());
|
||||
Assert.assertEquals(R.color.two_grade, new Grade().setValue("2=").getValueColor());
|
||||
Assert.assertEquals(R.color.one_grade, new Grade().setValue("1+").getValueColor());
|
||||
Assert.assertEquals(R.color.one_grade, new Grade().setValue("+1").getValueColor());
|
||||
Assert.assertEquals(R.color.default_grade, new Grade().setValue("Np").getValueColor());
|
||||
Assert.assertEquals(R.color.default_grade, new Grade().setValue("").getValueColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
Assert.assertTrue(new Grade().setSubject("Religia").setValue("5")
|
||||
.equals(new Grade().setSubject("Religia").setValue("5")));
|
||||
|
||||
Assert.assertFalse(new Grade().setSubject("Religia").setValue("4")
|
||||
.equals(new Grade().setSubject("Religia").setValue("5")));
|
||||
|
||||
Assert.assertEquals(new Grade().setSubject("Religia").setValue("5").hashCode(),
|
||||
new Grade().setSubject("Religia").setValue("5").hashCode());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user