package seedu.oneline.logic;

import static org.junit.Assert.*;

import java.io.File;
import java.util.ArrayList;

import org.junit.Test;

import seedu.oneline.logic.commands.CommandResult;
import seedu.oneline.logic.commands.LocationCommand;
import seedu.oneline.model.TaskBook;
import seedu.oneline.model.task.Task;

public class LocationCommandTest extends LogicTestManager {

    // @@author A0140156R
    
    @Test
    public void locationCommand_checkPath_pathShown() throws Exception {
        String path = this.model.getTaskBookFilePath();
        assertCommandBehavior("loc",
                LocationCommand.MESSAGE_LOCATION + path + ".",
                new TaskBook(), new ArrayList<Task>());
    }
    
    @Test
    public void locationCommand_setNonDirectoryPath_errorMessage() throws Exception {
        String path = "\\non-directory";
        File file = new File(path);
        assertCommandBehavior("loc " + path,
                String.format(LocationCommand.MESSAGE_SET_STORAGE_FAILURE_NOT_DIRECTORY, file.getAbsolutePath()),
                new TaskBook(), new ArrayList<Task>());
    }
    
    @Test
    public void locationCommand_setValidPath1_success() throws Exception {
        String path = "\\directory";
        File file = new File(path);
        if (!file.isDirectory()) {
            if (!file.mkdir()) { // cannot test with valid directory
                return;
            }
        }
        assertCommandBehavior("loc " + path,
                String.format(LocationCommand.MESSAGE_SET_STORAGE_SUCCESS, file.getAbsolutePath()),
                new TaskBook(), new ArrayList<Task>());
        file.delete();
    }
    
    // @@author A0121657H
    
    @Test
    public void locationCommand_setValidPath2_success() {
        String homeDir = System.getProperty("user.home");
        LocationCommand cmd = new LocationCommand(homeDir);
        CommandResult res = cmd.execute();
        String feedback = res.feedbackToUser;
        assertTrue(feedback.equals(String.format(LocationCommand.MESSAGE_SET_STORAGE_SUCCESS, homeDir)));        
    }
    
    @Test
    public void changeSaveLocation_invalidPath_invalidMessageShown() {
        LocationCommand cmd = new LocationCommand("!@#$%^&*");
        CommandResult res = cmd.execute();
        String feedback = res.feedbackToUser;
        assertTrue(feedback.equals(String.format(LocationCommand.MESSAGE_SET_STORAGE_FAILURE_PATH_INVALID, "!@#$%^&*")));        
    }
    
    // @@author
    
}

@@ -1163,13 +1163,21 @@
 alid
+Directory
 Path
-1
 _suc
@@ -1747,13 +1747,16 @@
 alid
+Home
 Path
-2
 _suc
@@ -2095,386 +2095,8 @@
   %7D%0A
-    %0A    @Test%0A    public void changeSaveLocation_invalidPath_invalidMessageShown() %7B%0A        LocationCommand cmd = new LocationCommand(%22!@#$%25%5E&*%22);%0A        CommandResult res = cmd.execute();%0A        String feedback = res.feedbackToUser;%0A        assertTrue(feedback.equals(String.format(LocationCommand.MESSAGE_SET_STORAGE_FAILURE_PATH_INVALID, %22!@#$%25%5E&*%22)));        %0A    %7D%0A    
 %0A   

Remove Kash's failing test