From 82ba42ec68bd26145c702df97e5adfa517cd485a Mon Sep 17 00:00:00 2001 From: bspeice Date: Mon, 14 Oct 2013 13:34:03 -0400 Subject: [PATCH] Add an example test case --- .../uncc/gameday/alerts/test/AlertDBTest.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/com/uncc/gameday/alerts/test/AlertDBTest.java diff --git a/src/com/uncc/gameday/alerts/test/AlertDBTest.java b/src/com/uncc/gameday/alerts/test/AlertDBTest.java new file mode 100644 index 0000000..1fd8ed2 --- /dev/null +++ b/src/com/uncc/gameday/alerts/test/AlertDBTest.java @@ -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(); + l.add(a1); + l.add(a2); + + dbHandle.persistMultiple(l); + assertEquals(2, getNumAlerts()); + } +}