include array.util.ArrayUtil

include file.util.FileUtil
include file.writer.FileWriter

include string.util.StringUtil

include test.executor.TestExecutor
include test.util.TestUtil

FileWriterTest(){
	run(){
		TestExecutor executeTest FileWriterTest
	}

	setUp(){
		local _testDir=$(FileUtil construct ${testDir})
	}

	tearDown(){
		rm -rf ${testDir}
	}

	testAppendExistingFile(){
		local testFile=$(FileUtil makeFile ${testFile})

		FileWriter append ${testFile} "this is a string"

		local content="this is a string"
		local fileContent=$(FileUtil getContent ${testFile})

		${assertEquals} content fileContent
	}

	testReplace(){
		FileWriter append ${testFile} "this is a string"
		FileWriter replace ${testFile} this that

		local content="that is a string"
		local fileContent=$(FileUtil getContent ${testFile})

		${assertEquals} content fileContent
	}

	local assertEquals="TestUtil assertEquals"
	local testDir=$(pwd)/bash-toolbox/test/dependencies
	local testFile=$(pwd)/bash-toolbox/test/dependencies/test.txt

	setUp

	$@

	tearDown
}
include array.util.ArrayUtil

include file.util.FileUtil
include file.writer.FileWriter

include string.util.StringUtil

include test.executor.TestExecutor
include test.util.TestUtil

FileWriterTest(){
	run(){
		TestExecutor executeTest FileWriterTest
	}

	setUp(){
		local _testDir=$(FileUtil construct ${testDir})
	}

	tearDown(){
		rm -rf ${testDir}
	}

	testAppendCreateFile(){
		local isNotFile=$(${assertDoesNotExist} testFile)

		local content="this is a string"

		FileWriter append ${testFile} "${content}"

		local fileContent=$(FileUtil getContent ${testFile})

		if [[ ${isNotFile} == PASS &&
			$(${assertExists} testFile) &&
			$(${assertEquals} content fileContent) ]]; then

			echo PASS
		else
			echo FAIL
		fi
	}

	testAppendExistingFile(){
		local testFile=$(FileUtil makeFile ${testFile})

		FileWriter append ${testFile} "this is a string"

		local content="this is a string"
		local fileContent=$(FileUtil getContent ${testFile})

		${assertEquals} content fileContent
	}

	testReplace(){
		FileWriter append ${testFile} "this is a string"
		FileWriter replace ${testFile} this that

		local content="that is a string"
		local fileContent=$(FileUtil getContent ${testFile})

		${assertEquals} content fileContent
	}

	local assertDoesNotExist="TestUtil assertDoesNotExist"
	local assertEquals="TestUtil assertEquals"
	local assertExists="TestUtil assertExists"
	local testDir=$(pwd)/bash-toolbox/test/dependencies
	local testFile=$(pwd)/bash-toolbox/test/dependencies/test.txt

	setUp

	$@

	tearDown
}
Add test to validate when FileWriter.append() creates a new file
Add test to validate when FileWriter.append() creates a new file
