aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/network
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-03-24 07:31:56 +0100
committerBananeweizen <bananeweizen@gmx.de>2012-03-24 07:31:56 +0100
commit2b5a1a7482178ec4773443cb1b0b2a174779a7da (patch)
treeccf1ef23b7da51999fe40a414e65521280de5661 /tests/src/cgeo/geocaching/network
parent51f56540932d83cb81549b817fccbca495e54c5a (diff)
downloadcgeo-2b5a1a7482178ec4773443cb1b0b2a174779a7da.zip
cgeo-2b5a1a7482178ec4773443cb1b0b2a174779a7da.tar.gz
cgeo-2b5a1a7482178ec4773443cb1b0b2a174779a7da.tar.bz2
refactoring: more encapsulation in SearchResult
Diffstat (limited to 'tests/src/cgeo/geocaching/network')
-rw-r--r--tests/src/cgeo/geocaching/network/ParametersTest.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/network/ParametersTest.java b/tests/src/cgeo/geocaching/network/ParametersTest.java
new file mode 100644
index 0000000..4c56f05
--- /dev/null
+++ b/tests/src/cgeo/geocaching/network/ParametersTest.java
@@ -0,0 +1,53 @@
+package cgeo.geocaching.network;
+
+import cgeo.geocaching.network.Parameters;
+
+import android.test.AndroidTestCase;
+
+import java.security.InvalidParameterException;
+
+import junit.framework.Assert;
+
+public class ParametersTest extends AndroidTestCase {
+
+ public static void testException() {
+ try {
+ final Parameters params = new Parameters("aaa", "AAA", "bbb");
+ params.clear(); // this will never be invoked, but suppresses warnings about unused objects
+ Assert.fail("Exception not raised");
+ } catch (InvalidParameterException e) {
+ // Ok
+ }
+ try {
+ final Parameters params = new Parameters("aaa", "AAA");
+ params.put("bbb", "BBB", "ccc");
+ Assert.fail("Exception not raised");
+ } catch (InvalidParameterException e) {
+ // Ok
+ }
+ }
+
+ public static void testMultipleValues() {
+ final Parameters params = new Parameters("aaa", "AAA", "bbb", "BBB");
+ params.put("ccc", "CCC", "ddd", "DDD");
+ Assert.assertEquals("aaa=AAA&bbb=BBB&ccc=CCC&ddd=DDD", params.toString());
+ }
+
+ public static void testSort() {
+ final Parameters params = new Parameters();
+ params.put("aaa", "AAA");
+ params.put("ccc", "CCC");
+ params.put("bbb", "BBB");
+ Assert.assertEquals("aaa=AAA&ccc=CCC&bbb=BBB", params.toString());
+ params.sort();
+ Assert.assertEquals("aaa=AAA&bbb=BBB&ccc=CCC", params.toString());
+ }
+
+ public static void testToString() {
+ final Parameters params = new Parameters();
+ params.put("name", "foo&bar");
+ params.put("type", "moving");
+ Assert.assertEquals("name=foo%26bar&type=moving", params.toString());
+ }
+
+}