/*
 * 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.BeforeClass;
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();

	@BeforeClass
	public static 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("\'aaa\': keyword could not be found.\n", TextBuddyPlusPlus.search("aaa"));
	}

	// Test Case2: Search valid keywords
	@Test
	public void testSearchValid() throws IOException {
		assertEquals("1. Meeting with Microsoft CEO at Headquarters, 2PM\n" +
				"2. Meeting with Facebook CEO at Alto Palo, 6PM\n", TextBuddyPlusPlus.search("CEO"));
	}

	// Test Case3: Search random keywords
	@Test
	public void testSearchRandom() throws IOException {
		assertEquals("1. Telepresence with Paypal Developer Team to discuss on policy management system, Thursday 5AM\n", TextBuddyPlusPlus.search("me"));
	}
}
@@ -2716,10 +2716,437 @@
 e%22));%0A%09%7D
+%0A%0A%09// Test Case4: Search case-sensitive keywords%0A%09@Test%0A%09public void testSearchCaseSensitive() throws IOException %7B%0A%09%09assertEquals(%22%5C'ceo%5C': keyword could not be found.%5Cn%22, TextBuddyPlusPlus.search(%22ceo%22));%0A%09%7D%0A%0A%09// Test Case5: Search case-sensitive keywords%0A%09@Test%0A%09public void testSearchCaseSensitive2() throws IOException %7B%0A%09%09assertEquals(%22%5C'meeting%5C': keyword could not be found.%5Cn%22, TextBuddyPlusPlus.search(%22meeting%22));%0A%09%7D
 %0A%7D

Version 0.1.8: Unit test for case-sensitive keywords.