/*
 * National University of Singapore
 * The MIT License (MIT)
 *
 * Copyright (c) 2014. Kenneth Ham Gao Jie (A0111875E)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package test;

import com.CS2103.TextBuddy_v2.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import java.io.IOException;

import org.junit.Before;
import org.junit.Test;

public class TextBuddyTest {
	private static final String APP_NAME = "TextBuddy";
	private static final String FILE_NAME = "in.txt";
	private static final String[] ARGS = {APP_NAME, FILE_NAME};
	private TextBuddyPlusPlus textbuddypp = new TextBuddyPlusPlus();

	@Before
	public void initialize() throws IOException {
		TextBuddyPlusPlus textbuddypp = new TextBuddyPlusPlus();
		textbuddypp.TextBuddy(ARGS);
	}

	// Test Case: Search Empty
	@Test
	public void testSearchEmpty() throws IOException {
		assertEquals("Search Invalid!", TextBuddyPlusPlus.search(""));
	}

	// Test Case1: Search invalid keyword
	@Test
	public void testSearchInvalid() throws IOException {
		assertEquals("\'a\': keyword could not be found.\n", TextBuddyPlusPlus.search("a"));
	}
}
@@ -1375,16 +1375,46 @@
 Before;%0A
+import org.junit.BeforeClass;%0A
 import o
@@ -1428,16 +1428,16 @@
 t.Test;%0A
-
 %0Apublic 
@@ -1698,16 +1698,21 @@
 %09@Before
+Class
 %0A%09public
@@ -1708,24 +1708,31 @@
 ass%0A%09public 
+static 
 void initial
@@ -2127,16 +2127,18 @@
 als(%22%5C'a
+aa
 %5C': keyw
@@ -2192,16 +2192,533 @@
 earch(%22a
+aa%22));%0A%09%7D%0A%0A%09// Test Case2: Search valid keywords%0A%09@Test%0A%09public void testSearchValid() throws IOException %7B%0A%09%09assertEquals(%221. Meeting with Microsoft CEO at Headquarters, 2PM%5Cn%22 +%0A%09%09%09%09%222. Meeting with Facebook CEO at Alto Palo, 6PM%5Cn%22, TextBuddyPlusPlus.search(%22CEO%22));%0A%09%7D%0A%0A%09// Test Case3: Search random keywords%0A%09@Test%0A%09public void testSearchRandom() throws IOException %7B%0A%09%09assertEquals(%221. Telepresence with Paypal Developer Team to discuss on policy management system, Thursday 5AM%5Cn%22, TextBuddyPlusPlus.search(%22me
 %22));%0A%09%7D%0A

Version 0.1.7: Unit test to search for a keyword. Search for characters as part of keyword search.