package eic.beike.projectx.network.projectXServer;

import junit.framework.TestCase;

/**
 * Test the database interaction. As of now this is against the live server.
 * Created by alex on 10/1/15.
 */
public class DatabaseTest extends TestCase {
    private Database db;

    /**
     * We use a fresh object for every test.
     * @throws Exception
     */
    public void setUp() throws Exception {
        super.setUp();
        db = new Database();

    }

    public void testRegister() throws Exception {
        String id = "test" + Long.toString(System.currentTimeMillis());
        //Should be able to register.
        boolean success = db.register(id, "alex");
        assertTrue(success);
        //Should not be able to register twice.
        success = db.register(id, "alex");
        assertFalse(success);
    }

    public void testRecordScore() throws Exception {

    }

    public void testGetTopTen() throws Exception {

    }

    public void testGetPlayerTopTen() throws Exception {

    }
}
@@ -868,32 +868,823 @@
 ows Exception %7B%0A
+        //Create two users.%0A        String id1 = %22test%22 + Long.toString(System.currentTimeMillis());%0A        String id2 = %22test%22 + Long.toString(System.currentTimeMillis() + 10);%0A        //Register one of them.%0A        if(db.register(id1, %22alex%22)) %7B%0A            //Record a valid score.%0A            long t = System.currentTimeMillis();%0A            boolean success = db.recordScore(id1,10,t,%22Ericsson$100020%22);%0A            assertTrue(success);%0A            //Try again. This should not be allowed.%0A            success = db.recordScore(id1,10,t,%22Ericsson$100020%22);%0A            assertFalse(success);%0A            //Try with unknown player, should not be allowed.%0A            success = db.recordScore(id2,10,System.currentTimeMillis(),%22Ericsson$100020%22);%0A            assertFalse(success);%0A        %7D
 %0A    %7D%0A%0A    publ

Add tests for recording a score.