package com.example.qyu4.theallswap;

import android.test.ActivityInstrumentationTestCase2;

/**
 * Created by qyu4 on 10/7/15.
 * this is the test file for testing user offline activities.
 * At the date Oct. 7th, 2015, this file is just a skeleton testfile and it does not
 * have it real functionality.
 */
public class OfflineUserActivityTest extends ActivityInstrumentationTestCase2 {
    public OfflineUserActivityTest(){
        super(UserEditInventoryActivity.class);
    }
    public void testNewItemCreated(){
        ArrayList<Item> itemList = new ArrayList<Item>();
        //TODO: creating item offline;
        Item itemOffline = new Item("offline item", "category", "offline item description");
        itemList.add(itemOffline);

        //TODO: get result while online
        //TODO: check if new result and item created when offline is equal.
        assertEqual("offline item", item.getName(0));
    }
    public void testAddItem(){
        assertTrue(testIsOffline());
        //TODO: reconnect internet;
        assertTrue(testIsOnline());
        //TODO: initialize a item name(string Type: itemName)
        //TODO: create an item setName(itemNam)
        //assertEquals(item.getName().equals(String));
    }
    public boolean testIsOffline(){
        boolean cantConnect = NetworkConnector.tryConnect(); 
        return not canConnect;
    }
    public boolean testIsOnline(){
        boolean canConnect = NetworkConnector.tryConnect(); 
        return true;
    }

}

@@ -738,17 +738,95 @@
 fline);%0A
+        assertEqual(%22offline item%22, String.vavlueOf(itemList.getItemIndex(0)))
 %0A
-
         
@@ -1036,36 +1036,735 @@
     
-assertTrue(testIsOffline());
+InternetConnection ic = new InternetConnection();%0A        ic.setInternet(false);%0A        assertTrue(testIsOffline());%0A        ArrayList%3CItem%3E itemList = new ArrayList%3CItem%3E();%0A        //TODO: creating item offline;%0A        Item itemOffline = new Item(%22offline item%22, %22category%22, %22offline item description%22);%0A        itemList.add(itemOffline);%0A        ic.setInternet(true);%0A        //TODO: get result while online%0A        //and load the result item into itemList %0A        ListItem.loadFile(itemList);%0A        %0A        assertEqual(%22offline item%22, String.vavlueOf(itemList.getItemIndex(0)));%0A        //TODO: check if new result and item created when offline is equal.%0A        assertEqual(%22offline item%22, item.getName(0));%0A        
 %0A   

Update OfflineUserActivityTest.java