Add an example test case

This commit is contained in:
bspeice 2013-10-14 13:34:03 -04:00
parent 6f45fb2216
commit 82ba42ec68

View File

@ -0,0 +1,64 @@
package com.uncc.gameday.alerts.test;
import java.util.Date;
import java.util.List;
import com.uncc.gameday.alerts.Alert;
import com.uncc.gameday.alerts.AlertDB;
import android.test.AndroidTestCase;
public class AlertDBTest extends AndroidTestCase {
private AlertDB dbHandle;
public AlertDBTest() throws Exception {
super.setUp();
dbHandle = new AlertDB();
}
public void setUp() {
// Drop all alerts
}
private int getNumAlerts() {
// Get the number of alerts currently in the database
return -1;
}
public void testPersist() {
// Create an alert and persist it
Alert a = new Alert();
a.setAlarmDate(new Date());
a.setMessage("testPersist");
a.setShown(false);
dbHandle.persist(a);
assertEquals(1, getNumAlerts());
}
public void testPersistUnique() {
// Make sure we can store alerts even when they have the same display date
Date d = new Date();
Alert a1 = new Alert(d, "testPersistUnique", false);
Alert a2 = new Alert(d, "testPersistUnique", false);
dbHandle.persist(a1);
dbHandle.persist(a2);
assertEquals(2, getNumAlerts());
}
public void testPersistMultiple() {
Date d = new Date();
Alert a1 = new Alert(d, "testPersistMultiple", false);
Alert a2 = new Alert(d, "testPersistMultiple", false);
List l = new List<Alert>();
l.add(a1);
l.add(a2);
dbHandle.persistMultiple(l);
assertEquals(2, getNumAlerts());
}
}