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

WFLocalDocUtilsTest.lua

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

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

NOTICE: All information contained herein is, and remains 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 are protected by all applicable
intellectual property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material is
strictly forbidden unless prior written permission is obtained from
Adobe Systems Incorporated.

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

local WFRxTestCase = require "WFRxTestCase"
local WFLocalDocUtils = require "WFLocalDocUtils"

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

local function rxTest_currentRevIdIsOnOz( rxTest )

	local ok = pcall( WFLocalDocUtils.currentRevIdIsOnOz  )

	rxTest:expectEqual( false, ok )

	ok = pcall( WFLocalDocUtils.currentRevIdIsOnOz, "bad arg" )

	rxTest:expectEqual( false, ok )

	rxTest:expectEqual( false, WFLocalDocUtils.currentRevIdIsOnOz( {} ) )

	rxTest:expectEqual( 
			false, 
			WFLocalDocUtils.currentRevIdIsOnOz( 
				{ _revId = "nope" } ) )

	rxTest:expectEqual( 
			false, 
			WFLocalDocUtils.currentRevIdIsOnOz( 
				{ 
					_revId = "nope",

					_serverProvidedMetadata = {

					}

				} ) )

	rxTest:expectEqual( 
			false, 
			WFLocalDocUtils.currentRevIdIsOnOz( 
				{ 
					_revId = "nope",

					_serverProvidedMetadata = {

						revision_ids = "nope"

					}

				} ) )

	local revId1 = "6f9af32c4a5f4f7fa7ebd6a4fc475f15"

	local revId2 = "7f9af32c4a5f4f7fa7ebd6a4fc475f15"

	local revId3 = "8f9af32c4a5f4f7fa7ebd6a4fc475f15"

	local revId4 = "9f9af32c4a5f4f7fa7ebd6a4fc475f15"

	rxTest:expectEqual( 
			false, 
			WFLocalDocUtils.currentRevIdIsOnOz( 
				{ 
					_revId = revId4,

					_serverProvidedMetadata = {

						revision_ids = { revId1, revId2, revId3 }

					}

				} ) )

	for _, revId in ipairs( { revId1, revId2, revId3 } ) do

		rxTest:expectEqual( 
				true, 
				WFLocalDocUtils.currentRevIdIsOnOz( 
					{ 
						_revId = revId,

						_serverProvidedMetadata = {

							revision_ids = { revId1, revId2, revId3 }

						}

					} ) )

	end

end

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

return WFRxTestCase.wrapSuite( {

	rxTest_currentRevIdIsOnOz = rxTest_currentRevIdIsOnOz,

} )
