Repository navigation
Expand file tree
/
Copy pathOrmLiteCreateTableWithIndexesTests.cs
More file actions
56 lines (45 loc) · 1.73 KB
/
Copy pathOrmLiteCreateTableWithIndexesTests.cs
File metadata and controls
56 lines (45 loc) · 1.73 KB
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
using NUnit.Framework;
using ServiceStack.Text;
using ServiceStack.Common.Tests.Models;
namespace ServiceStack.OrmLite.MySql.Tests
{
[TestFixture]
public class OrmLiteCreateTableWithIndexesTests
: OrmLiteTestBase
{
[Test]
public void Can_create_ModelWithIndexFields_table()
{
using (var db = OpenDbConnection())
{
db.CreateTable<ModelWithIndexFields>(true);
var sql = OrmLiteConfig.DialectProvider.ToCreateIndexStatements( typeof (ModelWithIndexFields) ).Join();
Assert.IsTrue(sql.Contains("idx_modelwithindexfields_name"));
Assert.IsTrue(sql.Contains("uidx_modelwithindexfields_uniquename"));
}
}
[Test]
public void Can_create_ModelWithCompositeIndexFields_table()
{
using (var db = OpenDbConnection())
{
db.CreateTable<ModelWithCompositeIndexFields>(true);
var sql = OrmLiteConfig.DialectProvider.ToCreateIndexStatements(typeof(ModelWithCompositeIndexFields)).Join();
Assert.IsTrue(sql.Contains("idx_modelwithcompositeindexfields_name"));
Assert.IsTrue(sql.Contains("idx_modelwithcompositeindexfields_composite1_composite2"));
}
}
[Test]
public void Can_create_ModelWithNamedCompositeIndex_table()
{
using (var db = OpenDbConnection())
{
db.CreateTable<ModelWithNamedCompositeIndex>(true);
var sql = OrmLiteConfig.DialectProvider.ToCreateIndexStatements(typeof(ModelWithNamedCompositeIndex)).Join();
Assert.IsTrue(sql.Contains("idx_modelwithnamedcompositeindex_name"));
Assert.IsTrue(sql.Contains("custom_index_name"));
Assert.IsFalse(sql.Contains("uidx_modelwithnamedcompositeindexfields_composite1_composite2"));
}
}
}
}