/
ExecuteTest.fs
68 lines (60 loc) · 2.01 KB
/
ExecuteTest.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//----------------------------------------------------------------------------
//
// Copyright (c) 2011 The Soma Team.
//
// This source code is subject to terms and conditions of the Apache License, Version 2.0. A
// copy of the license can be found in the License.txt file at the root of this distribution.
// By using this source code in any fashion, you are agreeing to be bound
// by the terms of the Apache License, Version 2.0.
//
// You must not remove this notice, or any other, from this software.
//----------------------------------------------------------------------------
namespace Soma.Core.IT
open System
open System.Configuration
open System.Data
open System.Data.Common
open System.Transactions
open NUnit.Framework
open Soma.Core
module ExecuteTest =
type Department =
{ [<Id>]
DepartmentId : int
DepartmentName : string
[<Version>]
VersionNo : int }
type Employee =
{ [<Id(IdKind.Identity)>]
EmployeeId : int option
EmployeeName : string option
DepartmentId : int option
[<Version>]
VersionNo : int option }
[<Test>]
let ``execute : insert``() =
use ts = new TransactionScope()
use con = SQLite.createConnection()
let rows =
SQLite.execute con "
insert into Department (DepartmentId, DepartmentName, VersionNo) values (/* id */0, /* name */'aaa', /* version */0)
" ["id" @= 99; "name" @= "hoge"; "version" @= 10]
assert_equal 1 rows
[<Test>]
let ``execute : update``() =
use ts = new TransactionScope()
use con = SQLite.createConnection()
let rows =
SQLite.execute con "
update Department set DepartmentName = 'hoge' where DepartmentId = /* id */-1 and VersionNo = /* versionNo */-1
" ["id" @= 1; "versionNo" @= 0]
assert_equal 1 rows
[<Test>]
let ``execute : delete``() =
use ts = new TransactionScope()
use con = SQLite.createConnection()
let rows =
SQLite.execute con "
delete from Department
" []
assert_equal 2 rows