--[[----------------------------------------------------------------------------

WFTestRunnerTest.lua

--------------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2015 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: All information contained herein is, and remain the property of
Adobe Systems Incorporated and its suppliers, if any. The intellectual and
technical concepts contained herein are proprietary to Adobe Systems
Incorporated and its suppliers and may be covered by U.S. and Foreign
Patents, patents in process, and are protected by trade secret or copyright
law.  Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

------------------------------------------------------------------------------]]

	-- WF.core.self_test
local WFRxTestCase = require 'WFRxTestCase'

	-- WF.core.utils
local KSPrefs = require 'KSPrefs'

	-- WF.core.logger
local WFLogger = require 'WFLogger'

--------------------------------------------------------------------------------

local logger = WFLogger 'WFTestRunnerTest'
logger:enable( 'print' )

--============================================================================--

local WFTestRunnerTest = {}

--------------------------------------------------------------------------------

local function assertPref( actual, expected )

	logger:infof( "Expecting %s, Actual %s", expected, actual )
	assert( actual == expected )

end

--------------------------------------------------------------------------------

 function WFTestRunnerTest.setUpClass()
 	
	logger:info( 'Now in function setUpClass' )
	
	local raceConditionPref = KSPrefs.rxTestRaceCondition
	
	if raceConditionPref then
	
		logger:infof( "Expecting %s, Actual %s", 'tearDownClass', raceConditionPref )

	end
	
	local fnName = 'setUpClass'
	KSPrefs.rxTestRaceCondition = fnName
	
 end

--------------------------------------------------------------------------------

 function WFTestRunnerTest.setUp()
 
 	logger:info( 'Now in function setUp' )
	
 	local raceConditionPref = KSPrefs.rxTestRaceCondition
	
	logger:infof( "Expecting %s or %s, Actual %s", 
			'setUpClass', 
			'tearDown',
			raceConditionPref )
			
	assert( 
		raceConditionPref == 'setUpClass' or
		raceConditionPref == 'tearDown' )
	
	local fnName = 'setUp'
	KSPrefs.rxTestRaceCondition = fnName
	
 end
 
--------------------------------------------------------------------------------
 
function WFTestRunnerTest.tearDown()

	logger:info( 'Now in function tearDown' )

	local raceConditionPref = KSPrefs.rxTestRaceCondition
	
	logger:infof( "Expecting %s or %s or %s, Actual %s",
			'test1',
			'test2',
			'test3', 
			raceConditionPref )

	assert( 
		raceConditionPref == 'test1' or
		raceConditionPref == 'test2' or
		raceConditionPref == 'test3' )
	
	local fnName = 'tearDown'
	KSPrefs.rxTestRaceCondition = fnName
	
end

--------------------------------------------------------------------------------

 function WFTestRunnerTest.tearDownClass()
 
 	logger:info( 'Now in function tearDownClass' )
	
 	local raceConditionPref = KSPrefs.rxTestRaceCondition
	
	assertPref( raceConditionPref, 'tearDown' )
	
	local fnName = 'tearDownClass'
	KSPrefs.rxTestRaceCondition = fnName
	
 end

--------------------------------------------------------------------------------

function WFTestRunnerTest.rxTestRaceCondition_1( rxTest )

	logger:info( 'Now in function rxTestRaceCondition_1' )
	
	local raceConditionPref = KSPrefs.rxTestRaceCondition
	
	assertPref( raceConditionPref, 'setUp' )
	
	local fnName = 'test1'
	KSPrefs.rxTestRaceCondition = fnName
	
end

--------------------------------------------------------------------------------

function WFTestRunnerTest.rxTestRaceCondition_2( rxTest )

	logger:info( 'Now in function rxTestRaceCondition_2' )
	
	local raceConditionPref = KSPrefs.rxTestRaceCondition
	
	assertPref( raceConditionPref, 'setUp' )
	
	local fnName = 'test2'
	KSPrefs.rxTestRaceCondition = fnName
	
end

--------------------------------------------------------------------------------

function WFTestRunnerTest.rxTestRaceCondition_3( rxTest )

	logger:info( 'Now in function rxTestRaceCondition_3' )
	
	local raceConditionPref = KSPrefs.rxTestRaceCondition
	
	assertPref( raceConditionPref, 'setUp' )
	
	local fnName = 'test3'
	KSPrefs.rxTestRaceCondition = fnName
	
end

--------------------------------------------------------------------------------

return WFRxTestCase.wrapSuite( WFTestRunnerTest )
