forked from bittercoder/Migrator.NET
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathGeneric_ConstraintExistsBase.cs
More file actions
38 lines (31 loc) · 1.21 KB
/
Generic_ConstraintExistsBase.cs
File metadata and controls
38 lines (31 loc) · 1.21 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
using System.Data;
using DotNetProjects.Migrator.Framework;
using Migrator.Tests.Providers.Base;
using NUnit.Framework;
namespace Migrator.Tests.Providers.Generic;
[TestFixture]
public abstract class Generic_ConstraintExistsBase : TransformationProviderBase
{
/// <summary>
/// Should return true if foreign key exists.
/// </summary>
[Test]
public void ConstraintExists_ForeignKeyExists_ReturnsTrue()
{
// Arrange
var tableName = "Task";
var fkName = "FK_Task_TaskGroup";
Provider.AddTable("Task",
new Column(name: "Id", type: DbType.Int32, property: ColumnProperty.PrimaryKey),
new Column(name: "TaskGroupId", type: DbType.Int32, property: ColumnProperty.Null)
);
Provider.AddTable("TaskGroup",
new Column(name: "Id", type: DbType.Int32, property: ColumnProperty.PrimaryKey)
);
Provider.AddForeignKey(name: fkName, childTable: tableName, childColumn: "TaskGroupId", parentTable: "TaskGroup", parentColumn: "Id");
// Act
var result = Provider.ConstraintExists(table: tableName, name: fkName);
// Assert
Assert.That(result, Is.True);
}
}