//////////////////////////////////////////////////
// AccountValidator

let accountValidator = new AccountValidator();

QUnit.test( "AccountValidator - isValidMaestroID", function( assert ) {
	let text = "";
	assert.equal(accountValidator.isValidMaestroID(text), false, "isValidMaestroID - no text");
	text = "1abcde";
	assert.equal(accountValidator.isValidMaestroID(text), false, "isValidMaestroID - " + text);
	text = "abc";
	assert.equal(accountValidator.isValidMaestroID(text), false, "isValidMaestroID - " + text);
	text = "a1b";
	assert.equal(accountValidator.isValidMaestroID(text), false, "isValidMaestroID - " + text);
	text = "abcdeabcdeabcdeabcdea";
	assert.equal(accountValidator.isValidMaestroID(text), false, "isValidMaestroID - " + text);

	text = "abcd";
	assert.equal(accountValidator.isValidMaestroID(text), true, "isValidMaestroID - " + text);
	text = "aA1Bccd";
	assert.equal(accountValidator.isValidMaestroID(text), true, "isValidMaestroID - " + text);
	text = "abcdeabcdeabcdeabcde";
	assert.equal(accountValidator.isValidMaestroID(text), true, "isValidMaestroID - " + text);
});

QUnit.test( "AccountValidator - isValidMaestroPW", function( assert ) {
	let text = "";
	assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
	text = "1";
	assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
	text = "12";
	assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
	text = "123";
	assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
	text = "1234";
	assert.equal(accountValidator.isValidMaestroPW(text), true, "isValidMaestroPW - " + text);
	text = "12345";
	assert.equal(accountValidator.isValidMaestroPW(text), true, "isValidMaestroPW - " + text);
	text = "123456";
	assert.equal(accountValidator.isValidMaestroPW(text), true, "isValidMaestroPW - " + text);
	text = "1234567891234567";
	assert.equal(accountValidator.isValidMaestroPW(text), true, "isValidMaestroPW - " + text);
	text = "12345678912345678";
	assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);

	text = "1abcde";
	assert.equal(accountValidator.isValidMaestroPW(text), true, "isValidMaestroPW - " + text);
	text = "abc";
	assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
	text = "a1b";
	assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
	text = "abcdeabcdeabcdeabcdea";
	assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
	text = "abcdeabcdeabcdeabcde";
	assert.equal(accountValidator.isValidMaestroPW(text), false, "isValidMaestroPW - " + text);
});


QUnit.test( "AccountValidator - isValidPlayerID", function( assert ) {
	let text = "";
	assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - no text");
	text = "1abcde";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "abc";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "a1b";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "abcdeabcdeabcdeabcdea";
	assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);

	text = "abcd";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "aA1Bccd";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "abcdeabcdeabcdeabcde";
	assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);

	text = "박지상";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "박지상76";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "박";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "ㅂ";
	assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);

	text = "박지상박세나";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "박지상박세나신현";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "박지상박세나ab";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "박지상박세나abc";
	assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
	text = "박지상박세나신현주";
	assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
	text = "박지상박세나123";
	assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);

	text = "1-3박세나";
	assert.equal(accountValidator.isValidPlayerID(text), true, "isValidPlayerID - " + text);
	text = "1-4 박지상";
	assert.equal(accountValidator.isValidPlayerID(text), false, "isValidPlayerID - " + text);
});

QUnit.test( "AccountValidator - isValidPlayerPW", function( assert ) {
	let text = "";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
	text = "1";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
	text = "12";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
	text = "123";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
	text = "1234";
	assert.equal(accountValidator.isValidPlayerPW(text), true, "isValidPlayerPW - " + text);
	text = "12345";
	assert.equal(accountValidator.isValidPlayerPW(text), true, "isValidPlayerPW - " + text);
	text = "123456";
	assert.equal(accountValidator.isValidPlayerPW(text), true, "isValidPlayerPW - " + text);
	text = "1234567";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);

	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - no text");
	text = "1abcde";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
	text = "abc";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
	text = "a1b";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
	text = "abcdeabcdeabcdeabcdea";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);

	text = "abcd";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
	text = "aA1Bccd";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
	text = "abcdeabcdeabcdeabcde";
	assert.equal(accountValidator.isValidPlayerPW(text), false, "isValidPlayerPW - " + text);
});



//////////////////////////////////////////////////
// TypingTextManager

let typingTextMan = new TypingTextManager();
let testContent = [ "ㅃ", "ㅂ", "ㅈ", "ㅉ", "ㄸ", "ㄷ", "ㄱ", "ㄲ", "ㅅ" ];

QUnit.test( "TypingTextManager - add", function( assert ) {
	typingTextMan.init();
	typingTextMan.add(testContent);
	let contents = typingTextMan.getContents();

	assert.equal(contents[0], "ㅃ", "addTextArray - ㅃ");
	assert.equal(contents[8], "ㅅ", "addTextArray - ㅅ");

	typingTextMan.add([ "k", "l" ]);
	contents = typingTextMan.getContents();

	assert.equal(contents[9], "k", "addTextArray - k");
	assert.equal(contents[10], "l", "addTextArray - l");
});

QUnit.test( "TypingTextManager - slice", function( assert ) {
	typingTextMan.init();
	typingTextMan.add(testContent);
	typingTextMan.slice(0, 3);
	let contents = typingTextMan.getContents();

	assert.equal(contents[0], "ㅃ", "slice - ㅃ");
	assert.equal(contents[2], "ㅈ", "slice - ㅈ");
	assert.equal(contents[3], undefined, "slice - ㅉ");
});

QUnit.test( "TypingTextManager - makePracticeContents", function( assert ) {
	typingTextMan.makePracticeContents(testContent, 2);
	let contents = typingTextMan.getContents();

	assert.equal(contents[0], "ㅃ", "makePracticeContents - ㅃ");
	assert.equal(contents[8], "ㅅ", "makePracticeContents - ㅅ");
	assert.equal(contents.length, testContent.length * 3, "makePracticeContents - length");
});

QUnit.test( "TypingTextManager - makeTestContents", function( assert ) {
	typingTextMan.makeTestContents(testContent);
	let contents = typingTextMan.getContents();

	assert.equal(contents.length, testContent.length, "makeTestContents - length");
});



//////////////////////////////////////////////////
// KeyMapper

let keyMapper = new KeyMapper();

QUnit.test( "KeyMapper - getNormalText", function( assert ) {
	assert.equal(keyMapper.getNormalText("Backquote"), "`", "getNormalText - `");
	assert.equal(keyMapper.getNormalText("Slash"), "/", "getNormalText - /");

	assert.equal(keyMapper.getNormalText("KeyQ", Keyboard.ENGLISH), "q", "getNormalText - q");
	assert.equal(keyMapper.getNormalText("KeyM", Keyboard.ENGLISH), "m", "getNormalText - m");

	assert.equal(keyMapper.getNormalText("KeyQ", Keyboard.KOREAN), "ㅂ", "getNormalText - ㅂ");
	assert.equal(keyMapper.getNormalText("KeyM", Keyboard.KOREAN), "ㅡ", "getNormalText - ㅡ");
});

QUnit.test( "KeyMapper - getShiftText", function( assert ) {
	assert.equal(keyMapper.getShiftText("Backquote"), "~", "getShiftText - ~");
	assert.equal(keyMapper.getShiftText("Slash"), "?", "getShiftText - ?");

	assert.equal(keyMapper.getShiftText("KeyQ", Keyboard.ENGLISH), "Q", "getShiftText - Q");
	assert.equal(keyMapper.getShiftText("KeyM", Keyboard.ENGLISH), "M", "getShiftText - M");

	assert.equal(keyMapper.getShiftText("KeyQ", Keyboard.KOREAN), "ㅃ", "getShiftText - ㅃ");
	assert.equal(keyMapper.getShiftText("KeyM", Keyboard.KOREAN), "ㅡ", "getShiftText - ㅡ");
});

/*
QUnit.test( "KeyMapper - getShiftHandSide", function( assert ) {
	assert.equal(keyMapper.getShiftHandSide("Backquote"), KeyTextData.RIGHT_HAND, "getShiftHandSide - `");
	assert.equal(keyMapper.getShiftHandSide("Slash"), KeyTextData.LEFT_HAND, "getShiftHandSide - /");

	assert.equal(keyMapper.getShiftHandSide("Space"), KeyTextData.BOTH_HAND, "getShiftHandSide - space");

	assert.equal(keyMapper.getShiftHandSide("KeyQ"), KeyTextData.RIGHT_HAND, "getShiftHandSide - q");
	assert.equal(keyMapper.getShiftHandSide("KeyM"), KeyTextData.LEFT_HAND, "getShiftHandSide - m");

	assert.equal(keyMapper.getShiftHandSide("KeyQ", Keyboard.KOREAN), KeyTextData.RIGHT_HAND, "getShiftHandSide - q");
	assert.equal(keyMapper.getShiftHandSide("KeyM", Keyboard.KOREAN), KeyTextData.LEFT_HAND, "getShiftHandSide - m");
});
*/



QUnit.test( "KeyMapper - getKeyIDOfText", function( assert ) {
	assert.equal(keyMapper.getKeyIDOfText("`"), "Backquote", "getKeyIDOfText - `");
	assert.equal(keyMapper.getKeyIDOfText("~"), "Backquote", "getKeyIDOfText - ~");
	assert.equal(keyMapper.getKeyIDOfText("/"), "Slash", "getKeyIDOfText - /");
	assert.equal(keyMapper.getKeyIDOfText("?"), "Slash", "getKeyIDOfText - ?");

	assert.equal(keyMapper.getKeyIDOfText("q"), "KeyQ", "getKeyIDOfText - q");
	assert.equal(keyMapper.getKeyIDOfText("Q"), "KeyQ", "getKeyIDOfText - Q");
	assert.equal(keyMapper.getKeyIDOfText("m"), "KeyM", "getKeyIDOfText - m");
	assert.equal(keyMapper.getKeyIDOfText("M"), "KeyM", "getKeyIDOfText - M");

	assert.equal(keyMapper.getKeyIDOfText("ㅂ"), "KeyQ", "getKeyIDOfText - ㅂ");
	assert.equal(keyMapper.getKeyIDOfText("ㅃ"), "KeyQ", "getKeyIDOfText - ㅃ");
	assert.equal(keyMapper.getKeyIDOfText("ㅡ"), "KeyM", "getKeyIDOfText - ㅡ");

	assert.equal(keyMapper.getKeyIDOfText("Backspace"), "Backspace", "getKeyIDOfText - ㅂ");
});

QUnit.test( "KeyMapper - isShiftText", function( assert ) {
	assert.equal(keyMapper.isShiftText("`"), false, "isShiftText - `");
	assert.equal(keyMapper.isShiftText("~"), true, "isShiftText - ~");
	assert.equal(keyMapper.isShiftText("/"), false, "isShiftText - /");
	assert.equal(keyMapper.isShiftText("?"), true, "isShiftText - ?");

	assert.equal(keyMapper.isShiftText("q"), false, "isShiftText - q");
	assert.equal(keyMapper.isShiftText("Q"), true, "isShiftText - Q");
	assert.equal(keyMapper.isShiftText("m"), false, "isShiftText - m");
	assert.equal(keyMapper.isShiftText("M"), true, "isShiftText - M");

	assert.equal(keyMapper.isShiftText("ㅁ"), false, "isShiftText - ㅁ");
	assert.equal(keyMapper.isShiftText("ㄴ"), false, "isShiftText - ㄴ");
	assert.equal(keyMapper.isShiftText("ㅇ"), false, "isShiftText - ㅇ");

	assert.equal(keyMapper.isShiftText("ㅂ"), false, "isShiftText - ㅂ");
	assert.equal(keyMapper.isShiftText("ㅃ"), true, "isShiftText - ㅃ");
	assert.equal(keyMapper.isShiftText("ㅡ"), false, "isShiftText - ㅡ");
});



//////////////////////////////////////////////////
// DBConnectManager

let dbConnectManager = new DBConnectManager();
dbConnectManager.setMaestroID(0);
dbConnectManager.setPlayerID(0);
dbConnectManager.setDateTime("2018-05-16", "14:50:00");

QUnit.test( "DBConnectManager - Player login", function( assert ) {
	let returnPlayerID = -1;

	let done = assert.async();
	setTimeout(function() {
		dbConnectManager.requestCheckPlayerLogin(
			"jisangs", "test", "111111",
			(jsonData) => {
				returnPlayerID = jsonData["PlayerID"];
				assert.equal(returnPlayerID, 31);
				done();
			},
			(jsonData) => {
				console.log(jsonData);
				done();
			}
		);
	});
});

QUnit.test( "DBConnectManager - Player history", function( assert ) {
	sessionStorageManager.maestroID = 1;	// jisangs
	sessionStorageManager.playerID = "8";	// 부현율
	sessionStorageManager.playingAppID = 29;
	let date = "2018-05-16";

	let done = assert.async();
	setTimeout(function() {
		dbConnectManager.requestPlayerHistory(
			1,	// maestroID for jisangs
			date,
			(historyRecordManager) => {
				// console.log(historyRecordManager);

				assert.equal(historyRecordManager.getAppNameAt(0), "test_korean_word");
				assert.equal(historyRecordManager.getDateAt(0), "2018-05-16");
				assert.equal(historyRecordManager.getBestRecordAt(0), 108.248);

				assert.equal(historyRecordManager.getAppNameAt(4), "test_korean_word");
				assert.equal(historyRecordManager.getDateAt(4), "2018-04-23");
				assert.equal(historyRecordManager.getBestRecordAt(4), 74.2234);

				done();
			}
		);
	});
});

QUnit.test( "DBConnectManager - Player ranking", function( assert ) {
	sessionStorageManager.maestroID = 1;	// jisangs
	sessionStorageManager.playingAppID = 29;
	let date = "2018-05-16";
	let time = "14:50:00";

	let done = assert.async(3);

	setTimeout(function() {
		dbConnectManager.requestRanking(
			DBConnectManager.TYPE_MY_RANKING_HOUR,
			1,	// maestroID for jisangs
			date,
			time,
			(type, rankingRecordManager) => {
				assert.equal(rankingRecordManager.getRankAt(0), 1, "hour");
				assert.equal(rankingRecordManager.getBestRecordAt(0), 302.921, "hour");
				assert.equal(rankingRecordManager.getPlayerIDAt(0), 5, "hour");
				assert.equal(rankingRecordManager.getPlayerNameAt(0), "김지유", "hour");

				assert.equal(rankingRecordManager.getRankAt(5), 6, "hour");
				assert.equal(rankingRecordManager.getBestRecordAt(5), 128.436, "hour");
				assert.equal(rankingRecordManager.getPlayerIDAt(5), 22, "hour");
				assert.equal(rankingRecordManager.getPlayerNameAt(5), "모윤건", "hour");

				done();
			}
		);
	});

	setTimeout(function() {
		dbConnectManager.requestRanking(
			DBConnectManager.TYPE_MY_RANKING_DAY,
			1,	// maestroID for jisangs
			date,
			time,
			(type, rankingRecordManager) => {
				assert.equal(rankingRecordManager.getRankAt(0), 1, "day");
				assert.equal(rankingRecordManager.getBestRecordAt(0), 313.304, "day");
				assert.equal(rankingRecordManager.getPlayerIDAt(0), 19, "day");
				assert.equal(rankingRecordManager.getPlayerNameAt(0), "오지운", "day");

				assert.equal(rankingRecordManager.getRankAt(17), 18, "day");
				assert.equal(rankingRecordManager.getBestRecordAt(17), 65.337, "day");
				assert.equal(rankingRecordManager.getPlayerIDAt(17), 20, "day");
				assert.equal(rankingRecordManager.getPlayerNameAt(17), "김민성", "day");

				done();
			}
		);
	});

	setTimeout(function() {
		dbConnectManager.requestRanking(
			DBConnectManager.TYPE_MY_RANKING_MONTH,
			1,	// maestroID for jisangs
			date,
			time,
			(type, rankingRecordManager) => {
				assert.equal(rankingRecordManager.getRankAt(0), 1, "month");
				assert.equal(rankingRecordManager.getBestRecordAt(0), 617.231, "month");
				assert.equal(rankingRecordManager.getPlayerIDAt(0), 50, "month");
				assert.equal(rankingRecordManager.getPlayerNameAt(0), "강민준", "month");

				assert.equal(rankingRecordManager.getRankAt(17), 18, "month");
				assert.equal(rankingRecordManager.getBestRecordAt(17), 216.279, "month");
				assert.equal(rankingRecordManager.getPlayerIDAt(17), 9, "month");
				assert.equal(rankingRecordManager.getPlayerNameAt(17), "신예성", "month");

				done();
			}
		);
	});

});

QUnit.test( "DBConnectManager - HowToPlay", function( assert ) {
	let howToPlayForSpaceInvaders = "외계인이 나타났다!\\n마우스 왼쪽 버튼으로\\n외계인을 클릭해서 물리쳐 주세요.";

	let done = assert.async(2);

	setTimeout(function() {
		dbConnectManager.requestHowToPlay(
			101,	// space_invaders app ID
			(jsonData) => {
				let howToPlay = jsonData["HowToPlay"];
				assert.equal(howToPlay, howToPlayForSpaceInvaders);
				done();
			},
			(jsonData) => {
				console.log(jsonData);
				done();
			}
		);

		dbConnectManager.requestHowToPlay(
			1,	// korean basic typing
			(jsonData) => {
				let howToPlay = jsonData["HowToPlay"];
				assert.equal(howToPlay, "");
				done();
			},
			(jsonData) => {
				console.log(jsonData);
				done();
			}
		);
	});
});


QUnit.test( "DBConnectManager - UpdateRecord", function( assert ) {
	let todayBestRecord = 0;

	let done = assert.async();

	setTimeout(function() {
		dbConnectManager.requestTodayBestRecord(
			1,	// maestro ID for "jisangs"
			1,	// Player ID for jisangs
			101,	// space_invaders app ID
			(jsonData) => {
				todayBestRecord = jsonData["BestRecord"];
			},
			(jsonData) => {
				console.log(jsonData);
				todayBestRecord = 0;
			}
		);
	});

	setTimeout(function() {
		dbConnectManager.updateTodayBestRecord(
			1,	// maestro ID for "jisangs"
			1,	// Player ID for jisangs
			101,	// space_invaders app ID
			todayBestRecord + 1000	// new record
		);
	}, 100);

	setTimeout(function() {
		dbConnectManager.requestTodayBestRecord(
			1,	// maestro ID for "jisangs"
			1,	// Player ID for jisangs
			101,	// space_invaders app ID
			(jsonData) => {
				let bestRecord = jsonData["BestRecord"];
				assert.equal(bestRecord, todayBestRecord + 1000);
				done();
			},
			(jsonData) => {
				console.log(jsonData);
				done();
			}
		);
	}, 200);
});


//////////////////////////////////////////////////
// HeartManager

let heartManager = new HeartManager();

QUnit.test( "HeartManager - MaxCount", function( assert ) {
	heartManager.setCount(3);
	assert.equal(heartManager.getCount(), 3);

	heartManager.setMaxCount(5);
	assert.equal(heartManager.getCount(), 3);

	heartManager.setMaxCount(3);
	assert.equal(heartManager.getCount(), 3);

	heartManager.setMaxCount(2);
	assert.equal(heartManager.getCount(), 2);
});


QUnit.test( "HeartManager - setCount", function( assert ) {
	heartManager.setMaxCount(3);

	heartManager.setCount(3);
	assert.equal(heartManager.getCount(), 3);

	heartManager.setCount(2);
	assert.equal(heartManager.getCount(), 2);
});


QUnit.test( "HeartManager - addHearts", function( assert ) {
	heartManager.setMaxCount(3);

	heartManager.setCount(1);
	assert.equal(heartManager.getCount(), 1);

	heartManager.addHearts(1);
	assert.equal(heartManager.getCount(), 2);

	heartManager.setCount(1);
	assert.equal(heartManager.getCount(), 1);

	heartManager.addHearts(2);
	assert.equal(heartManager.getCount(), 3);

	heartManager.setCount(1);
	assert.equal(heartManager.getCount(), 1);

	heartManager.addHearts(3);
	assert.equal(heartManager.getCount(), 3);
});


QUnit.test( "HeartManager - breakHearts", function( assert ) {
	heartManager.setMaxCount(3);

	heartManager.setCount(3);
	assert.equal(heartManager.getCount(), 3);

	heartManager.breakHearts(1);
	assert.equal(heartManager.getCount(), 2);

	heartManager.breakHearts(2);
	assert.equal(heartManager.getCount(), 0);
});


//////////////////////////////////////////////////
// HistoryRecordManager

let historyRecordManager = new HistoryRecordManager();

historyRecordManager.push(new HistoryRecord("05/10", "space_invaders", 1000));
historyRecordManager.push(new HistoryRecord("05/11", "typing_korean_basic", 100));
historyRecordManager.push(new HistoryRecord("05/12", "cooking_meats", 200));
historyRecordManager.push(new HistoryRecord("05/13", "typing_english_basic", 2000));
historyRecordManager.push(new HistoryRecord("05/14", "test", 10000));

QUnit.test( "HistoryRecordManager - push", function( assert ) {
	assert.equal(historyRecordManager.count, 5);
});

QUnit.test( "HistoryRecordManager - getAt", function( assert ) {
	assert.equal(historyRecordManager.getDateAt(0), "05/10");
	assert.equal(historyRecordManager.getDateAt(4), "05/14");

	assert.equal(historyRecordManager.getAppNameAt(0), "space_invaders");
	assert.equal(historyRecordManager.getAppNameAt(4), "test");
});

QUnit.test( "HistoryRecordManager - clear", function( assert ) {
	let historyRecordManagerForClear = new HistoryRecordManager();
	historyRecordManagerForClear.push(new HistoryRecord("05/10", "space_invaders", 1));
	historyRecordManagerForClear.clear();

	assert.equal(historyRecordManagerForClear.count, 0);
});

QUnit.test( "HistoryRecordManager - underValueForGraph", function( assert ) {
	assert.equal(historyRecordManager.underValueForGraph(), 100);
});

QUnit.test( "HistoryRecordManager - upperValueForGraph", function( assert ) {
	assert.equal(historyRecordManager.upperValueForGraph(), 10000);
});



//////////////////////////////////////////////////
// NumberUtil

QUnit.test( "NumberUtil - NumberWithCommas", function( assert ) {
	assert.equal(NumberUtil.numberWithCommas(1), "1", "NumberWithCommas");
	assert.equal(NumberUtil.numberWithCommas(1000), "1,000", "NumberWithCommas");
	assert.equal(NumberUtil.numberWithCommas(100000), "100,000", "NumberWithCommas");
	assert.equal(NumberUtil.numberWithCommas(1000000), "1,000,000", "NumberWithCommas");
});

QUnit.test( "NumberUtil - NumberOfDigits", function( assert ) {
	assert.equal(NumberUtil.numberOfDigits(1), 1);
	assert.equal(NumberUtil.numberOfDigits(10), 2);
	assert.equal(NumberUtil.numberOfDigits(100), 3);
	assert.equal(NumberUtil.numberOfDigits(999), 3);
	assert.equal(NumberUtil.numberOfDigits(1000), 4);
	assert.equal(NumberUtil.numberOfDigits(9999), 4);
	assert.equal(NumberUtil.numberOfDigits(10000), 5);
	assert.equal(NumberUtil.numberOfDigits(99999), 5);
});


//////////////////////////////////////////////////
// RankingRecordManager

let rankingRecordManager = new RankingRecordManager();

rankingRecordManager.push(new RankingRecord(4, 1, "김남희", 1400));
rankingRecordManager.push(new RankingRecord(5, 2, "고봉순", 900));
rankingRecordManager.push(new RankingRecord(6, 3, "파르마", 800));
rankingRecordManager.push(new RankingRecord(7, 4, "박지상", 700));
rankingRecordManager.push(new RankingRecord(8, 5, "신현주", 600));

QUnit.test( "RankingRecordManager - push", function( assert ) {
	assert.equal(rankingRecordManager.count, 5);
});

QUnit.test( "RankingRecordManager - getAt", function( assert ) {
	assert.equal(rankingRecordManager.getRankAt(0), 4);
	assert.equal(rankingRecordManager.getRankAt(4), 8);

	assert.equal(rankingRecordManager.getPlayerIDAt(0), 1);
	assert.equal(rankingRecordManager.getPlayerIDAt(4), 5);

	assert.equal(rankingRecordManager.getPlayerNameAt(0), "김남희");
	assert.equal(rankingRecordManager.getPlayerNameAt(4), "신현주");

	assert.equal(rankingRecordManager.getBestRecordAt(0), 1400);
	assert.equal(rankingRecordManager.getBestRecordAt(4), 600);
});

QUnit.test( "RankingRecordManager - clear", function( assert ) {
	let rankingRecordManagerForClear = new RankingRecordManager();
	rankingRecordManagerForClear.push(new RankingRecord(8, "신현주", 600));
	rankingRecordManagerForClear.clear();

	assert.equal(rankingRecordManagerForClear.count, 0);
});


//////////////////////////////////////////////////
// ScoreManager

let scoreManager = new ScoreManager();

QUnit.test( "ScoreManager - plusScore", function( assert ) {
	assert.equal(scoreManager.score, 0);
	scoreManager.plusScore(10);
	assert.equal(scoreManager.score, 10);
	scoreManager.minusScore(10);
	assert.equal(scoreManager.score, 0);
});


//////////////////////////////////////////////////
// SessionStorageManager

QUnit.test( "SessionStorageManager - PlayerName", function( assert ) {
	sessionStorageManager.clear();
	assert.equal(sessionStorageManager.playerName, null, "playerName");

	sessionStorageManager.playerName = "박지상";
	assert.equal(sessionStorageManager.playerName, "박지상", "playerName");

	sessionStorageManager.removeItem("playerName");
	assert.equal(sessionStorageManager.playerName, null, "playerName");
});

QUnit.test( "SessionStorageManager - playerPlayerID", function( assert ) {
	sessionStorageManager.clear();
	assert.equal(sessionStorageManager.playerID, null, "playerID");

	sessionStorageManager.playerID = 1;
	assert.equal(sessionStorageManager.playerID, 1, "playerID");

	sessionStorageManager.removeItem("playerID");
	assert.equal(sessionStorageManager.playerID, null, "playerID");
});

QUnit.test( "SessionStorageManager - playingAppName", function( assert ) {
	sessionStorageManager.clear();
	assert.equal(sessionStorageManager.playingAppName, null, "playingAppName");

	sessionStorageManager.playingAppName = "space_invaders";
	assert.equal(sessionStorageManager.playingAppName, "space_invaders", "playingAppName");

	sessionStorageManager.removeItem("playingAppName");
	assert.equal(sessionStorageManager.playingAppName, null, "playingAppName");
});



//////////////////////////////////////////////////
// test

QUnit.test( "hello test", function( assert ) {
  assert.ok( 1 == "1", "Passed!" );
});