package ca.ualberta.cs.swapmyride;

import android.test.ActivityInstrumentationTestCase2;

/**
 * Created by Conner on 15-10-08.
 */
public class PhotoTest extends ActivityInstrumentationTestCase2 {
    public PhotoTest(){
        super(MainMenu.class);
    }

    public void testAddPhotoToItem(){
        Item item = new Item();
        item.setPhoto(picture);
        assertTrue(item.getPhoto().equals(photo));

        Boolean thrown = false;
        try {
            item.setPhoto(tooLargePicture);
        } catch (Exception e){
            thrown = true;
        }
        assertTrue(thrown);
    }

    public void testViewPhoto(){
        Item item = new Item();

        Boolean thrown = false;
        try {
            item.getPhoto();  // no photo set yet
        } catch (Exception e){
            thrown = true;
        }
        assertTrue(thrown);

        item.setPhoto(picture);
        Boolean thrown2 = false;
        try {
            item.getPhoto();  // shouldn't throw an error, photo is added
        } catch (Exception e){
            thrown2 = true;
        }
        assertFalse(thrown2);
    }
}

@@ -1118,10 +1118,588 @@
 ;%0A    %7D%0A
-%7D
+%0A    public void testDeletePhoto()%7B%0A        Item item = new Item();%0A%0A        Boolean thrown = false;%0A        try %7B%0A            item.deletePhoto();  // no photo, error%0A        %7D catch (Exception e)%7B%0A            thrown = true;%0A        %7D%0A        assertTrue(thrown);%0A%0A        item.setPhoto(picture);%0A        assertTrue(item.getPhoto().equals(photo));%0A        Boolean thrown2 = false;%0A        try %7B%0A            item.deletePhoto();  // shouldn't throw an error, photo is added%0A        %7D catch (Exception e)%7B%0A            thrown2 = true;%0A        %7D%0A        assertFalse(thrown2);%0A%0A    %7D%0A%7D%0A
 %0A

Use Case 25: Delete Photo