blob: f8a4f856ca1074fdb7f074bdcdbed2dae8d6a6c0 (
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
|
package cgeo.geocaching.twitter;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.Trackable;
import cgeo.geocaching.settings.Settings;
import cgeo.geocaching.settings.TestSettings;
import junit.framework.TestCase;
public class TwitterTest extends TestCase {
public static void testTrackableMessage() {
final String oldMessage = Settings.getTrackableTwitterMessage();
try {
TestSettings.setTrackableTwitterMessage("I touched [NAME] ([URL]).");
Trackable tb = new Trackable();
tb.setName("Travel bug");
tb.setGeocode("TB1234");
assertEquals("I touched Travel bug (http://www.geocaching.com//track/details.aspx?tracker=TB1234). #cgeo #geocaching", Twitter.getStatusMessage(tb));
} finally {
TestSettings.setTrackableTwitterMessage(oldMessage);
}
}
public static void testCacheMessage() {
final String oldMessage = Settings.getCacheTwitterMessage();
try {
TestSettings.setCacheTwitterMessage("I found [NAME] ([URL]).");
Geocache cache = new Geocache();
cache.setGeocode("GC1234");
cache.setName("TwitterTest");
assertEquals("I found TwitterTest (http://coord.info/GC1234). #cgeo #geocaching", Twitter.getStatusMessage(cache));
} finally {
TestSettings.setCacheTwitterMessage(oldMessage);
}
}
public static void testAvoidDuplicateTags() {
final String oldMessage = Settings.getCacheTwitterMessage();
try {
TestSettings.setCacheTwitterMessage("[NAME] #cgeo");
Geocache cache = new Geocache();
cache.setGeocode("GC1234");
cache.setName("TwitterTest");
assertEquals("TwitterTest #cgeo #geocaching", Twitter.getStatusMessage(cache));
} finally {
TestSettings.setCacheTwitterMessage(oldMessage);
}
}
}
|