mirror of
				https://github.com/bspeice/UNCCGameDay-Test
				synced 2025-11-04 02:10:36 -05:00 
			
		
		
		
	Add an example test case
This commit is contained in:
		
							
								
								
									
										64
									
								
								src/com/uncc/gameday/alerts/test/AlertDBTest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								src/com/uncc/gameday/alerts/test/AlertDBTest.java
									
									
									
									
									
										Normal 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());
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user