blob: f9e25bff10bd19bc8ccf3e5c6706eb2e2909d634 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package cgeo.geocaching.enumerations;
import static org.assertj.core.api.Assertions.assertThat;
import org.apache.commons.lang3.StringUtils;
import android.test.AndroidTestCase;
public class CacheAttributeTest extends AndroidTestCase {
public static void testTrimAttributeName() {
for (CacheAttribute attribute : CacheAttribute.values()) {
final String rawName = attribute.rawName;
assertThat(CacheAttribute.trimAttributeName(rawName)).as("attribute name").isEqualTo(rawName);
}
}
public static void testIds() {
for (CacheAttribute attribute : CacheAttribute.values()) {
if (attribute != CacheAttribute.UNKNOWN) {
assertThat(StringUtils.isNotEmpty(attribute.rawName)).isTrue();
assertThat(attribute.drawableId != 0).isTrue();
assertThat(attribute.stringIdYes != 0).isTrue();
assertThat(attribute.stringIdNo != 0).isTrue();
}
}
}
public static void testGetL10n() {
final CacheAttribute attribute = CacheAttribute.HIKING;
// This test is language dependent. It does not make sense to test it
// with every attribute. We just want to know if getL10n works
// correctly
assertFalse("_yes and _no must not have the same translation",
attribute.getL10n(true).equals(attribute.getL10n(false)));
}
public static void testGetBy() {
final CacheAttribute attribute = CacheAttribute.HIKING; // an attribute that is present in GC and OC
assertThat(attribute.gcid).overridingErrorMessage("Test cannot be run with this attribute").isGreaterThanOrEqualTo(0);
assertThat(attribute.ocacode).overridingErrorMessage("Test cannot be run with this attribute").isGreaterThanOrEqualTo(0);
assertThat(attribute).isSameAs(CacheAttribute.getByRawName(attribute.rawName));
assertThat(attribute).isSameAs(CacheAttribute.getByOcACode(attribute.ocacode));
}
public static void testIsEnabled() {
final String hiking_yes = "hiking_yes";
final String hiking_no = "hiking_no";
assertThat(CacheAttribute.isEnabled(hiking_yes)).isTrue();
assertThat(CacheAttribute.isEnabled(hiking_no)).isFalse();
}
}
|