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

KSIdGeneratorTest.lua

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

ADOBE CONFIDENTIAL
------------------
Copyright 2011 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.

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

local KSIdGeneratorTest = {}

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

local KSIdGenerator = require 'KSIdGenerator'

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

function KSIdGeneratorTest.testLocalCounter()

	local id1 = KSIdGenerator.localCounter()
	local id2 = KSIdGenerator.localCounter()
	
	assert( type( id1 ) == 'number', "id1 wasn't a number" )
	assert( type( id2 ) == 'number', "id2 wasn't a number" )

	assert( id2 > id1, "id2 wasn't > id1" )

end

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

function KSIdGeneratorTest.testUuid()

	local id1 = KSIdGenerator.uuid()
	local id2 = KSIdGenerator.uuid()
	
	assert( type( id1 ) == 'string', "id1 wasn't a string" )
	assert( type( id2 ) == 'string', "id2 wasn't a string" )

	assert( id1 ~= id2, "huh ... UUIDs were the same" )

end

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

function KSIdGeneratorTest.testUuidInLowercaseHex()

	local id1 = KSIdGenerator.uuidInLowercaseHex()
	local id2 = KSIdGenerator.uuidInLowercaseHex()
	
	assert( type( id1 ) == 'string', "id1 wasn't a string" )
	assert( type( id2 ) == 'string', "id2 wasn't a string" )

	assert( #id1 == 32, "id1 wasn't 32 digits" )
	assert( #id2 == 32, "id2 wasn't 32 digits" )

	assert( string.lower( id1 ) == id1, "id1 wasn't lowercase" )
	assert( string.lower( id2 ) == id2, "id2 wasn't lowercase" )

	assert( id1 ~= id2, "huh ... UUIDs were the same" )

end

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

return KSIdGeneratorTest
