Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 851cb9e

Browse files
committed
Merge branch 'master' of http://github.com/ServiceStack/ServiceStack.OrmLite into postgres_bytea
2 parents 747958d + 0fbf47a commit 851cb9e

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using NUnit.Framework;
2+
using ServiceStack.Common.Tests.Models;
3+
4+
namespace ServiceStack.OrmLite.Tests
5+
{
6+
public class OrmLiteDropTableWithNamingStrategyTests
7+
: OrmLiteTestBase
8+
{
9+
[Test]
10+
public void Can_drop_TableWithNamigStrategy_table_prefix()
11+
{
12+
OrmLiteConfig.DialectProvider.NamingStrategy = new PrefixNamingStrategy
13+
{
14+
TablePrefix = "tab_",
15+
ColumnPrefix = "col_"
16+
};
17+
18+
using (var db = ConnectionString.OpenDbConnection())
19+
{
20+
db.CreateTable<ModelWithOnlyStringFields>(true);
21+
22+
db.DropTable<ModelWithOnlyStringFields>();
23+
24+
Assert.False(db.TableExists("tab_ModelWithOnlyStringFields"));
25+
}
26+
27+
OrmLiteConfig.DialectProvider.NamingStrategy = new OrmLiteNamingStrategyBase();
28+
}
29+
30+
[Test]
31+
public void Can_drop_TableWithNamigStrategy_table_lowered()
32+
{
33+
OrmLiteConfig.DialectProvider.NamingStrategy = new LowercaseNamingStrategy();
34+
35+
using (var db = ConnectionString.OpenDbConnection())
36+
{
37+
db.CreateTable<ModelWithOnlyStringFields>(true);
38+
39+
db.DropTable<ModelWithOnlyStringFields>();
40+
41+
Assert.False(db.TableExists("modelwithonlystringfields"));
42+
}
43+
44+
OrmLiteConfig.DialectProvider.NamingStrategy = new OrmLiteNamingStrategyBase();
45+
}
46+
47+
48+
[Test]
49+
public void Can_drop_TableWithNamigStrategy_table_nameUnderscoreCompound()
50+
{
51+
OrmLiteConfig.DialectProvider.NamingStrategy = new UnderscoreSeparatedCompoundNamingStrategy();
52+
53+
using (var db = ConnectionString.OpenDbConnection())
54+
{
55+
db.CreateTable<ModelWithOnlyStringFields>(true);
56+
57+
db.DropTable<ModelWithOnlyStringFields>();
58+
59+
Assert.False(db.TableExists("model_with_only_string_fields"));
60+
}
61+
62+
OrmLiteConfig.DialectProvider.NamingStrategy = new OrmLiteNamingStrategyBase();
63+
}
64+
}
65+
}

tests/ServiceStack.OrmLite.Tests/ServiceStack.OrmLite.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
<Compile Include="Expression\UnaryExpressionsTest.cs" />
116116
<Compile Include="ForeignKeyAttributeTests.cs" />
117117
<Compile Include="OrmLiteDropTableTests.cs" />
118+
<Compile Include="OrmLiteDropTableWithNamingStrategyTests.cs" />
118119
<Compile Include="OrmLiteQueryTests.cs" />
119120
<Compile Include="LocalizationTests.cs" />
120121
<Compile Include="OrmLiteConnectionFactoryTests.cs" />

0 commit comments

Comments
 (0)