Skip to content

Commit 94db2b5

Browse files
Merge pull request #81 from dotnetprojects/postgre-test-reactivation
Postgre test reactivation
2 parents db05a49 + 0c119d4 commit 94db2b5

8 files changed

+97
-54
lines changed

src/Migrator.Tests/Migrator.Tests.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@
2828

2929
<ItemGroup>
3030
<Reference Include="System.Configuration" />
31-
<Reference
32-
Include="System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
33-
<HintPath>..\..\lib\System.Data.SqlServerCe.dll</HintPath>
34-
<SpecificVersion>False</SpecificVersion>
35-
</Reference>
3631
</ItemGroup>
3732

3833
<ItemGroup>

src/Migrator.Tests/Providers/Base/TransformationProviderBase.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,7 @@ public void AppliedMigrations()
292292
Assert.That(Provider.TableExists("SchemaInfo"), Is.True, "No SchemaInfo table created");
293293
}
294294

295-
/// <summary>
296-
/// Reproduce bug reported by Luke Melia & Daniel Berlinger :
297-
/// http://macournoyer.wordpress.com/2006/10/15/migrate-nant-task/#comment-113
298-
/// </summary>
295+
299296
[Test]
300297
public void CommitTwice()
301298
{
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Data;
3+
using Migrator.Framework;
4+
using Npgsql;
5+
using NUnit.Framework;
6+
7+
namespace Migrator.Tests.Providers.PostgreSQL;
8+
9+
[TestFixture]
10+
[Category("Postgre")]
11+
public class PostgreSQLTransformationProvider_PrimaryKeyWithIdentityTests : PostgreSQLTransformationProviderTestBase
12+
{
13+
[Test]
14+
public void AddTableWithPrimaryKeyIdentity_Succeeds()
15+
{
16+
// Arrange
17+
const string testTableName = "MyDefaultTestTable";
18+
const string propertyName1 = "Color1";
19+
const string propertyName2 = "Color2";
20+
21+
Provider.AddTable(testTableName,
22+
new Column(propertyName1, DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
23+
new Column(propertyName2, DbType.Int32, ColumnProperty.Unsigned)
24+
);
25+
26+
// Act
27+
Provider.Insert(testTableName, [propertyName2], [1]);
28+
Provider.Insert(testTableName, [propertyName2], [1]);
29+
30+
// Assert
31+
using (var command = Provider.GetCommand())
32+
{
33+
using var reader = Provider.ExecuteQuery(command, $"SELECT max({propertyName1}) as max from {testTableName}");
34+
reader.Read();
35+
36+
var primaryKeyValue = reader.GetInt32(reader.GetOrdinal("max"));
37+
Assert.That(primaryKeyValue, Is.EqualTo(2));
38+
}
39+
40+
// Act II
41+
var exception = Assert.Throws<PostgresException>(() => Provider.Insert(testTableName, [propertyName1, propertyName2], [1, 888]));
42+
43+
// Assert II
44+
Assert.That(exception.Message, Does.Contain("cannot insert a non-DEFAULT value into column"));
45+
}
46+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System.Data;
2+
using Microsoft.Data.SqlClient;
3+
using Migrator.Framework;
4+
using Migrator.Tests.Providers.SQLServer.Base;
5+
using NUnit.Framework;
6+
7+
namespace Migrator.Tests.Providers.SQLServer;
8+
9+
[TestFixture]
10+
[Category("SqlServer")]
11+
public class SqlServerTransformationProvider_NVARCHARnTests : SQLServerTransformationProviderTestBase
12+
{
13+
[Test]
14+
public void AddTableWithFixedLengthEqualTo4000Characters_ShouldCreateNVARCHAR4000()
15+
{
16+
// Arrange
17+
const string testTableName = "MyDefaultTestTable";
18+
const string propertyName1 = "Color1";
19+
20+
Provider.AddTable(testTableName,
21+
new Column(propertyName1, DbType.String, 4000)
22+
);
23+
24+
var stringLength4001 = new string('A', 4001);
25+
26+
// Act
27+
var exception = Assert.Throws<SqlException>(() => Provider.Insert(testTableName, [propertyName1], [stringLength4001]));
28+
29+
Assert.That(exception.Errors[0].Message, Does.Contain("String or binary data would be truncated"));
30+
}
31+
32+
[Test]
33+
public void AddTableWithFixedLengthGreaterThan4000Characters_ShouldCreateNVARCHARMAX()
34+
{
35+
// Arrange
36+
const string testTableName = "MyDefaultTestTable";
37+
const string propertyName1 = "Color1";
38+
39+
40+
Provider.AddTable(testTableName,
41+
new Column(propertyName1, DbType.String, 4001)
42+
);
43+
44+
var stringLength5000 = new string('A', 5000);
45+
46+
// Act
47+
Provider.Insert(testTableName, [propertyName1], [stringLength5000]);
48+
}
49+
}

src/Migrator.Tests/Providers/SQLServer/SqlServerTransformationProviderGenericTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
#endregion
1313

1414
using System.Data;
15-
using DotNetProjects.Migrator.Providers.Impl.SQLite;
1615
using Migrator.Providers;
17-
using Migrator.Providers.SQLite;
1816
using Migrator.Providers.SqlServer;
19-
using Migrator.Tests.Providers.Base;
2017
using Migrator.Tests.Settings;
2118
using Migrator.Tests.Settings.Config;
2219
using NUnit.Framework;

src/Migrator.Tests/Providers/SQLServer2005/SqlServer2005TransformationProviderTest.cs

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/Migrator/Framework/ColumnProperty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public enum ColumnProperty
3737
Indexed = 1 << 4,
3838

3939
/// <summary>
40-
/// Unsigned Column. Not used in SQLite there is only on integer data type INTEGER.
40+
/// Unsigned Column. Not used in SQLite there is only one integer data type => INTEGER.
4141
/// </summary>
4242
Unsigned = 1 << 5,
4343

0 commit comments

Comments
 (0)