From c1228f54411e11f373efb9c9d3205ec04ff9c0c7 Mon Sep 17 00:00:00 2001 From: koem Date: Mon, 11 Feb 2013 11:26:50 +1300 Subject: Unit-Tests ++ - and Maintenance Icon Color changed to alert-red --- .../enumerations/CacheAttributeTest.java | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tests/src/cgeo') diff --git a/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java b/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java index f369b0e..e5573ba 100644 --- a/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java +++ b/tests/src/cgeo/geocaching/enumerations/CacheAttributeTest.java @@ -6,7 +6,7 @@ public class CacheAttributeTest extends AndroidTestCase { public static void testTrimAttributeName() { for (CacheAttribute attribute : CacheAttribute.values()) { - final String rawName = attribute.gcRawName; + final String rawName = attribute.rawName; assertTrue("bad attribute name " + rawName, CacheAttribute.trimAttributeName(rawName).equals(rawName)); } } @@ -14,10 +14,39 @@ public class CacheAttributeTest extends AndroidTestCase { public static void testIds() { for (CacheAttribute attribute : CacheAttribute.values()) { if (attribute != CacheAttribute.UNKNOWN) { + assertTrue(attribute.rawName != null); + assertTrue(attribute.rawName.length() > 0); assertTrue(attribute.drawableId != 0); assertTrue(attribute.stringIdYes != 0); assertTrue(attribute.stringIdNo != 0); } } } + + public static void testGetL10n() { + CacheAttribute attribute = CacheAttribute.HIKING; + // This test is language dependend. 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() { + CacheAttribute attribute = CacheAttribute.HIKING; // an attribute that is present in GC and OC + assertTrue("Test cannot be run with this attribute", attribute.gcid >= 0); + assertTrue("Test cannot be run with this attribute", attribute.ocid >= 0); + assertSame(CacheAttribute.getByRawName(attribute.rawName), attribute); + assertSame(CacheAttribute.getByGcId(attribute.gcid), attribute); + assertSame(CacheAttribute.getByOcId(attribute.ocid), attribute); + } + + public static void testIsEnabled() { + CacheAttribute attribute = CacheAttribute.HIKING; + String hiking_yes = attribute.getAttributeName(true); + String hiking_no = attribute.getAttributeName(false); + assertTrue(CacheAttribute.isEnabled(hiking_yes)); + assertFalse(CacheAttribute.isEnabled(hiking_no)); + } + } -- cgit v1.1