package cmput301w16t15.shareo;

import android.test.ActivityInstrumentationTestCase2;

/**
 * Created by Larin on 2016/2/11.
 */
public class ProfileTest extends ActivityInstrumentationTestCase2{
    public ProfileTest() {
        super(MainActivity.class);
    }

 //03.01.01 As a user, I want a profile with a unique username and my contact information.
    public void testAddUser() {
        User testUser = new User("Jack","Jack Snow","123@ualberta.ca","7807091234");

        //Initialize user contact information
        testUser.setName("Jack");
        testUser.setFullName("Jack Snow");
        testUser.setEmailAddress("123@ualberta.ca");
        testUser.setMotto("7807091234");

        //Check to see if that is set to the user
        assertEquals(testUser.getName(), "Jack");
        assertEquals(testUser.getFullName(), "Jack Snow");
        assertEquals(testUser.getEmailAddress(), "123@ualberta.ca");
        assertEquals(testUser.getMotto(), "7807091234");

    }

//03.02.01 As a user, I want to edit the contact information in my profile
    public void testEditUser() {
        User testUser = new User("Jack","Jack Snow","123@ualberta.ca","7807091234");

        //Initialize user contact information
        testUser.setName("Jack");
        testUser.setFullName("Jack Snow");
        testUser.setEmailAddress("123@ualberta.ca");
        testUser.setMotto("7807091234");

        //Check to see if that is set to the user
        assertEquals(testUser.getName(), "Jack");
        assertEquals(testUser.getFullName(), "Jack Snow");
        assertEquals(testUser.getEmailAddress(), "123@ualberta.ca");
        assertEquals(testUser.getMotto(), "7807091234");

        //Edit the user information
        testUser.setEmailAddress("shareo@ualberta.ca");
        testUser.setMotto("7807094321");

        //Check to see if the user information is updated
        assertEquals(testUser.getEmailAddress(), "shareo@ualberta.ca");
        assertEquals(testUser.getMotto(), "7807094321");

    }
        //03.03.01 As a user, I want to, when a username is presented for a thing, retrieve and show
    // its contact information
    public void testViewRentersInfo () {
        //Create User
        User testUser = new User("Jack","Jack Snow","123@ualberta.ca","7807091234");
        Thing testThings = new Thing("Killer"," Role playing game","Part Game","9-20", Thing.Status.AVAILABLE);
        testThings.setOwnerSimple(testUser);
        testThings.setStatus(Thing.Status.BIDDED);

        //Simulate a click on an object where that user owns it
        //fail if I add this command
        //seems like that we cannot connect the relationship between adding things to user and bidding
        //assertTrue(testUser.getOwnedBiddedThings().contains(testThings.getName()));

        assertEquals(testUser.getName(), "Jack");
        assertEquals(testUser.getFullName(), "Jack Snow");
        assertEquals(testUser.getEmailAddress(), "123@ualberta.ca");
        assertEquals(testUser.getMotto(), "7807091234");
    }
    
     //03.03.01 As a user, I want to, when a username is presented for a thing, retrieve and show
    // its contact information
    public void testViewRentersInfo () {
        //Create User
        User testUser = new User("Jack","Jack Snow","123@ualberta.ca","7807091234");
        Thing testThings = new Thing("Killer"," Role playing game","Part Game","9-20", Thing.Status.AVAILABLE);
        //not available at this moment, since we only due with the user who is on the server.
        //testUser.addOwnedThing(testThings);
        testThings.setStatus(Thing.Status.BIDDED);

        //Simulate a click on an object where that user owns it
        //fail if I add this command
        //seems like that we cannot connect the relationship between adding things to user and bidding
        //assertTrue(testUser.getOwnedBiddedThings().contains(testThings.getName()));

        assertEquals(testUser.getName(), "Jack");
        assertEquals(testUser.getFullName(), "Jack Snow");
        assertEquals(testUser.getEmailAddress(), "123@ualberta.ca");
        assertEquals(testUser.getMotto(), "7807091234");
    }

}

@@ -3162,32 +3162,39 @@
 tion%0A    public 
+static 
 void testViewRen
@@ -3241,324 +3241,480 @@
     
-User testUser = new User(%22Jack%22,%22Jack Snow%22,%22123@ualberta.ca%22,%227807091234%22);%0A        Thing testThings = new Thing(%22Killer%22,%22 Role playing game%22,%22Part Game%22,%229-20%22, Thing.Status.AVAILABLE);%0A        //not available at this moment, since we only due with the user who is on the server.%0A        //testUser.addOwned
+ShareoData data = ShareoData.getInstance();%0A        User testUser = null;%0A        String fullName = %22Jack Snow%22;%0A        String emailAddress = %22123@ualberta.ca%22;%0A        String motto = %227807091234%22;%0A        data.removeUser(%22Jack%22);%0A%0A%0A        try %7B%0A            testUser = new User.Builder(data, %22Jack%22, fullName, emailAddress, motto).build();%0A        %7D catch (UsernameAlreadyExistsException e) %7B%0A            e.printStackTrace();%0A            fail();%0A        %7D%0A        
 Thing
-(
+ 
 test
@@ -3719,17 +3719,23 @@
 stThings
-)
+ = null
 ;%0A      
@@ -3741,59 +3741,156 @@
    t
-estThings.setStatus(Thing.Status.BIDDED
+ry %7B%0A            testThings = new Thing.Builder(data, testUser, %22Killer%22, %22Role playing game,%22,%22Part Game%22,%229-20%22).useMainThread().build(
 );%0A
-%0A
         
 //Si
@@ -3889,531 +3889,290 @@
     
-//Simulate a click on an object where that user owns it%0A        //fail if I add this command%0A        //seems like that we cannot connect the relationship between adding things to user and bidding%0A        //assertTrue(testUser.getOwnedBiddedThings().contains(testThings.getName()));%0A%0A        assertEquals(testUser.getName(), %22Jack%22);%0A        assertEquals(testUser.getFullName(), %22Jack Snow%22);%0A        assertEquals(testUser.getEmailAddress(), %22123@ualberta.ca%22);%0A        assertEquals(testUser.getMotto(), %227807091234%22
+%7D catch (UserDoesNotExistException e) %7B%0A            e.printStackTrace();%0A            fail();%0A        %7D%0A        testThings.setStatus(Thing.Status.BIDDED);%0A%0A        //Simulate a click on an object where that user owns it%0A        assertTrue(testThings.getOwner().equals(testUser)
 );%0A
+%0A
     %7D%0A
-%0A%7D%0A

edit profile test