aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/twitter/TwitterTest.java
blob: a27e57a9dff3856c72bbb6cba9a8671a2a7861b8 (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
package cgeo.geocaching.twitter;

import cgeo.geocaching.Geocache;
import cgeo.geocaching.Settings;
import cgeo.geocaching.Trackable;

import junit.framework.TestCase;

public class TwitterTest extends TestCase {

    public static void testTrackableMessage() {
        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));
    }

    public static void testCacheMessage() {
        Geocache cache = new Geocache();
        cache.setGeocode("GC1234");
        cache.setName("TwitterTest");
        assertEquals("I found TwitterTest (http://coord.info/GC1234) #cgeo #geocaching", Twitter.getStatusMessage(cache));
    }

    public static void testAvoidDuplicateTags() {
        String oldMessage = Settings.getCacheTwitterMessage();
        try {
            Geocache cache = new Geocache();
            cache.setGeocode("GC1234");
            cache.setName("TwitterTest");
            Settings.setCacheTwitterMessage("[NAME] #cgeo");
            assertEquals("TwitterTest #cgeo #geocaching", Twitter.getStatusMessage(cache));
        } finally {
            Settings.setCacheTwitterMessage(oldMessage);
        }
    }
}