# -------------------------------------------------------
# File: "SaveCmd.test"
#                        Created: 2004-09-07 15:43:09
#              Last modification: 2009-03-05 08:35:51
# Author: Bernard Desgraupes
# e-mail: <bdesgraupes@users.sourceforge.net.fr>
# www: <http://tcladdressbook.sourceforge.net>
# (c) Copyright: Bernard Desgraupes, 2004-2009
# All rights reserved.
# This software is free software with BSD licence.
# Versions history: see the Changes.Log file.
# 
# Test suite for the Tcl [addressbook save] command defined 
# in the Tcladdressbook extension.
# 
# -------------------------------------------------------

source [file join [file dir [info script]] TclABCommonTests.tcl]

namespace eval ::addressbook::test {
	namespace import ::tcltest::*

	variable SaveTestPersonID
	
	test AddressbookSave-1-1 {} -setup {
	} -body {
		if {![addressbook changed]} {
			set SaveTestPersonID [addressbook create person TclABSaveTestPerson]
			addressbook save
			return [addressbook changed]
		} 
		return 0
	} -cleanup {
		if {[info exists SaveTestPersonID]} {
			addressbook delete $SaveTestPersonID
			addressbook save
		} 
	} -result "0"
			
	# Usage string
	# ============
	test AddressbookSave-2-1 {Usage string for wrong num args} -setup {
	} -body {
		addressbook save extraArg
	} -cleanup {
	} -returnCodes error \
	  -result "wrong # args: should be \"addressbook save\""

	# Cleanup
	::tcltest::cleanupTests
}

namespace delete ::addressbook::test

