#!/usr/bin/env bash
#clear
#export PS4='\e[90m+${LINENO} in ${#BASH_SOURCE[@]}>${FUNCNAME[0]}:${BASH_SOURCE[@]##*/} \e[0m'
#set -x

level=$1
if [ -z "$level" ]; then
  level=1
fi
echo "starting: ${BASH_SOURCE[@]##*/} <?LOG_LEVEL=$level>"

#echo "sourcing init"
source this
source test.suite

log.level $level

competionArray=(once config list file ite)
source oo

test.c2() 
{
((TEST_COUNTER++))
console.log "


Test 0: c2 \"$*\"
===================================================================="
c2.start "$@"
console.log "RETURN: $RETURN_VALUE  Result: $RESULT 
===================================================================="
}

# test.case - "c2 without parameter" \
#    c2 
# expect 0 "*" "Test start"


source c2

fullQualifiedScript="$(cd $(dirname $0)/../test/test.data; pwd)/parameterTestScript"

# # ---- 
# test.case - "c2 behaves like 'c2 parameterTestScript o'" \
#    c2.completion.discover 1 cur parameterTestScript o p1 p2
# expect 0 "5" "expected 5 completion result lines"
# # works

# # ---- 
# test.case - "c2 with parameterTestScript without parameter" \
#    c2 parameterTestScript 
# expect 0 "*" "expected usage output without error"

# # ----
# # warn.log "$fullQualifiedScript"
# # stop.log "ENV"
# test.case - "c2 with full qualified script" \
#    c2 $(cd $(dirname $0)/../test/test.data; pwd)/parameterTestScript
# expect 0 "*" "expected usage output without error"
# # works

# # ----
# test.case - "c2 with full qualified script" \
#    c2.completion.discover 1 cur $fullQualifiedScript o
# expect 0 "5" "expected 5 completion result lines"
# # works

# # ----
# test.case - "c2 with script with method create" \
#    c2.completion.discover 1 cur $fullQualifiedScript o
# expect 0 "5" "expected 5 completion result lines"
# #works

# # ----
# test.case - "c2 with script with method one and value p1" \
#    c2.completion.discover 2 cur $fullQualifiedScript one p1
# RESULT="$(cat $CONFIG_PATH/completion.result.txt)"
# expect 0 "p1" "got expeted p1"
# #works


# # ----
#  test.case - "c2 behaves like 'c2 parameterTestScript oneDefaultValueQ'" \
#     c2.completion.discover 1 cur $fullQualifiedScript oneDefaultValueQ
# expect 0 "1" "expected 1 completion result line"
# RESULT="$(cat $CONFIG_PATH/completion.result.txt)"
# expect 0 "oneDefaultValueQuotes" "got expected oneDefaultValueQuotes"


# # ----
test.case - "c2 behaves like 'c2 parameterTestScript noop'" \
   c2.completion.discover 3 cur $fullQualifiedScript noop 
RESULT="$(cat $CONFIG_PATH/completion.result.txt)"
expect 0 ";"
# # fails

#  # tesing the outout of 'c2 parameterTestScript c'
#  test.case - "c2 behaves like 'c2 parameterTestScript create '" \
#     c2.completion.discover 2 cur parameterTestScript create 
# RESULT="$(cat $CONFIG_PATH/completion.result.txt)"
# expect 0 "addDefaultValue"

### test.method

