mirror of
https://github.com/bspeice/UNCCGameDay-Test
synced 2024-12-22 06:38:14 -05:00
Tests for the RegistrationClient are now up to date.
This commit is contained in:
parent
fe8838b189
commit
3eb8903197
@ -4,14 +4,16 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import android.util.Log;
|
||||
|
||||
import com.uncc.gameday.R;
|
||||
import com.uncc.gameday.registration.ParkingChoices;
|
||||
import com.uncc.gameday.registration.ParkingLot;
|
||||
import com.uncc.gameday.registration.ParkingRating;
|
||||
import com.uncc.gameday.registration.RatingChoices;
|
||||
import com.uncc.gameday.registration.RegistrationClient;
|
||||
|
||||
import android.net.http.AndroidHttpClient;
|
||||
import android.test.AndroidTestCase;
|
||||
|
||||
/* Tests the REST functionality */
|
||||
|
||||
public class RegistrationClientTest extends AndroidTestCase {
|
||||
@ -30,7 +32,7 @@ public class RegistrationClientTest extends AndroidTestCase {
|
||||
*/
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL("http", mContext.getString(R.string.server_hostname), "")
|
||||
.openConnection();
|
||||
if (connection.getResponseCode() != connection.HTTP_OK)
|
||||
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK)
|
||||
fail("Could not connect to GameDay! Response code: " + connection.getResponseCode());
|
||||
}
|
||||
|
||||
@ -45,5 +47,30 @@ public class RegistrationClientTest extends AndroidTestCase {
|
||||
ParkingLot lot = rc.listLot(ParkingChoices.BLUE);
|
||||
assertTrue(lot.getLocation().getValue() == ParkingChoices.BLUE.getValue());
|
||||
}
|
||||
|
||||
public void testRateLot() throws InterruptedException {
|
||||
RegistrationClient rc = new RegistrationClient(this.mContext);
|
||||
ParkingChoices choice = ParkingChoices.BLUE;
|
||||
|
||||
// To test and make sure this works:
|
||||
// Rate a lot empty 10 times to flush out any other ratings,
|
||||
// then rate it full 15 times. Check to make sure the value is correct.
|
||||
// Technically, should only need 10 POSTs, but been having some strange
|
||||
// issues where they don't seem to all make it to the server.
|
||||
// Sometimes the test will pass, sometimes it won't...
|
||||
for (int i = 0; i < 10; i++) {
|
||||
rc.rateLot(RatingChoices.EMP, choice);
|
||||
}
|
||||
|
||||
ParkingRating rating = new ParkingRating();
|
||||
rating.setParkingLot(choice);
|
||||
rating.setRating(RatingChoices.FLL);
|
||||
for (int i = 0; i < 15; i++) {
|
||||
rc.rateLot(rating);
|
||||
}
|
||||
|
||||
ParkingLot lot = rc.listLot(choice);
|
||||
assertEquals(100, lot.getFilledPct()); // FULL -> 100%
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user