###############################################################################
#
# tkt-a4d9c7ee94.eagle --
#
# Written by Joe Mistachkin.
# Released to the public domain, use at your own risk!
#
###############################################################################

package require Eagle
package require Eagle.Library
package require Eagle.Test

runTestPrologue

###############################################################################

package require System.Data.SQLite.Test
runSQLiteTestPrologue
runSQLiteTestFilesPrologue

###############################################################################

runTest {test tkt-a4d9c7ee94-1.1 {LINQ w/BinaryGUID=false} -body {
  #
  # NOTE: Re-copy the reference database file used for this unit test to the
  #       build directory in case it has been changed by a previous test run.
  #
  file copy -force $northwindEfDbFile \
      [file join [getBuildDirectory false] [file tail $northwindEfDbFile]]

  set result [list]
  set output ""

  set code [catch {
    testClrExec $testLinqExeFile [list -eventflags Wait -directory \
        [file dirname $testLinqExeFile] -nocarriagereturns -stdout output \
        -success 0] -binaryguid2 false
  } error]

  tlog "---- BEGIN STDOUT OUTPUT\n"
  tlog $output
  tlog "\n---- END STDOUT OUTPUT\n"

  lappend result $code

  if {$code == 0} then {
    lappend result [string trim $output]
  } else {
    lappend result [string trim $error]
  }

  set result
} -cleanup {
  unset -nocomplain code output error result
} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll testExec\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db} \
-constraintExpression {[haveConstraint buildFramework.netFx40] || \
[haveConstraint buildFramework.netFx45] || \
[haveConstraint buildFramework.netFx451] || \
[haveConstraint buildFramework.netFx452] || \
[haveConstraint buildFramework.netFx46] || \
[haveConstraint buildFramework.netFx461] || \
[haveConstraint buildFramework.netFx462]} \
-result {0 {1581 1730 1833 2116 2139 2184 2903 3049 3801 6897 7960 8837 10019\
10038 11747 14450 19428 19713 20852 27403 27511 29202 30346 31406 32859 33607\
40222 44122 45839 48075 48084 48304 53404 55113 55439 60179 60601 72716 75234\
78759 80202 80909 85014 85251 90405 94025 94105 95008 95054 95060 98004 98052\
98104}}}

###############################################################################

runTest {test tkt-a4d9c7ee94-1.2 {LINQ w/BinaryGUID=true} -body {
  #
  # NOTE: Re-copy the reference database file used for this unit test to the
  #       build directory in case it has been changed by a previous test run.
  #
  file copy -force $northwindEfDbFile \
      [file join [getBuildDirectory false] [file tail $northwindEfDbFile]]

  set result [list]
  set output ""

  set code [catch {
    testClrExec $testLinqExeFile [list -eventflags Wait -directory \
        [file dirname $testLinqExeFile] -nocarriagereturns -stdout output \
        -success 0] -binaryguid2 true
  } error]

  tlog "---- BEGIN STDOUT OUTPUT\n"
  tlog $output
  tlog "\n---- END STDOUT OUTPUT\n"

  lappend result $code

  if {$code == 0} then {
    lappend result [string trim $output]
  } else {
    lappend result [string trim $error]
  }

  set result
} -cleanup {
  unset -nocomplain code output error result
} -constraints {eagle monoToDo SQLite file_System.Data.SQLite.dll testExec\
file_System.Data.SQLite.Linq.dll file_testlinq.exe file_northwindEF.db} \
-constraintExpression {[haveConstraint buildFramework.netFx40] || \
[haveConstraint buildFramework.netFx45] || \
[haveConstraint buildFramework.netFx451] || \
[haveConstraint buildFramework.netFx452] || \
[haveConstraint buildFramework.netFx46] || \
[haveConstraint buildFramework.netFx461] || \
[haveConstraint buildFramework.netFx462]} \
-result {0 {1581 1730 1833 2116 2139 2184 2903 3049 3801 6897 7960 8837 10019\
10038 11747 14450 19428 19713 20852 27403 27511 29202 30346 31406 32859 33607\
40222 44122 45839 48075 48084 48304 53404 55113 55439 60179 60601 72716 75234\
78759 80202 80909 85014 85251 90405 94025 94105 95008 95054 95060 98004 98052\
98104}}}

###############################################################################

runSQLiteTestFilesEpilogue
runSQLiteTestEpilogue
runTestEpilogue
