| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
using System; |
| 12 |
using System.Data; |
| 13 |
using System.IO; |
| 14 |
using System.Text; |
| 15 |
using Mono.Data.Sqlite; |
| 16 |
using NUnit.Framework; |
| 17 |
|
| 18 |
namespace MonoTests.Mono.Data.Sqlite |
| 19 |
{ |
| 20 |
[TestFixture] |
| 21 |
public class SqliteFunctionTest |
| 22 |
{ |
| 23 |
string uri; |
| 24 |
|
| 25 |
[SetUp] |
| 26 |
public void SetUp () |
| 27 |
{ |
| 28 |
uri = Path.GetTempFileName (); |
| 29 |
} |
| 30 |
|
| 31 |
[TearDown] |
| 32 |
public void TearDown () |
| 33 |
{ |
| 34 |
if (File.Exists (uri)) |
| 35 |
File.Delete (uri); |
| 36 |
} |
| 37 |
|
| 38 |
[Test] |
| 39 |
public void CollationTest() |
| 40 |
{ |
| 41 |
var builder = new SqliteConnectionStringBuilder(); |
| 42 |
builder.DataSource = uri; |
| 43 |
|
| 44 |
var connectionString = builder.ToString(); |
| 45 |
using (var connection = new SqliteConnection (connectionString)) { |
| 46 |
connection.Open (); |
| 47 |
connection.Close (); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
[SqliteFunction(Name = "TestCollation", FuncType = FunctionType.Collation)] |
| 52 |
public class TestCollation : SqliteFunction |
| 53 |
{ |
| 54 |
public override int Compare (string param1, string param2) |
| 55 |
{ |
| 56 |
return string.Compare (param1, param2); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
[SqliteFunction(Name = "TestScalar", FuncType = FunctionType.Scalar)] |
| 61 |
public class TestScalar : SqliteFunction |
| 62 |
{ |
| 63 |
public override object Invoke (object[] args) |
| 64 |
{ |
| 65 |
return null; |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
[SqliteFunction(Name = "TestAggregate", FuncType = FunctionType.Aggregate)] |
| 70 |
public class TestAggregate : SqliteFunction |
| 71 |
{ |
| 72 |
public override void Step(object[] args, int stepNumber, ref object contextData) |
| 73 |
{ |
| 74 |
} |
| 75 |
|
| 76 |
public override object Final (object contextData) |
| 77 |
{ |
| 78 |
return null; |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
} |