-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
350 additions
and
42 deletions.
There are no files selected for viewing
24 changes: 21 additions & 3 deletions
24
EfCore.NamingConverter.Tests/Conventions/ColumnNameConventionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
namespace EfCore.NamingConverter.Tests.Conventions | ||
using EfCore.NamingConverter.Conventions; | ||
using EfCore.NamingConverter.Converters; | ||
using EfCore.NamingConverter.Tests.TestCases; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
|
||
namespace EfCore.NamingConverter.Tests.Conventions | ||
{ | ||
public class ColumnNameConventionTest | ||
{ | ||
// TODO: The test is not implemented yet | ||
[Fact] | ||
public void ProcessPropertyAdded_UseSnakeCaseLower_ShouldApplyColumnNameConvention() | ||
{ | ||
var convention = new ColumnNameConvention(NameConverter.SnakeCaseLower); | ||
var entityType = MockBuilder.BuildEntityType(b => b.Entity<SomeEntity>(), convention); | ||
var property = entityType.GetProperty(nameof(SomeEntity.SomeProperty)); | ||
|
||
var identifier = StoreObjectIdentifier.Create(entityType, StoreObjectType.Table).GetValueOrDefault(); | ||
|
||
var columnName = property.GetColumnName(identifier); | ||
|
||
Assert.Equal("some_property", columnName); | ||
} | ||
} | ||
} | ||
} |
22 changes: 20 additions & 2 deletions
22
EfCore.NamingConverter.Tests/Conventions/ForeignKeyNameConventionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
namespace EfCore.NamingConverter.Tests.Conventions | ||
using EfCore.NamingConverter.Conventions; | ||
using EfCore.NamingConverter.Converters; | ||
using EfCore.NamingConverter.Tests.TestCases; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EfCore.NamingConverter.Tests.Conventions | ||
{ | ||
public class ForeignKeyNameConventionTest | ||
{ | ||
// TODO:The test is not implemented yet | ||
[Fact] | ||
public void ProcessForeignKeyAdded_UseSnakeCaseLower_ShouldReturnSnakeCaseLower() | ||
{ | ||
var convention = new ForeignKeyNameConvention(NameConverter.SnakeCaseLower); | ||
var model = MockBuilder.BuildModel(b => b.Entity<Blog>(), convention); | ||
var entityType = model.FindEntityType(typeof(Post)); | ||
|
||
Assert.NotNull(entityType); | ||
|
||
string? foreignKeyName = entityType.GetForeignKeys().Single().GetConstraintName(); | ||
|
||
Assert.NotNull(foreignKeyName); | ||
Assert.Equal("fk_post_blog_blog_id", foreignKeyName); | ||
} | ||
} | ||
} |
20 changes: 18 additions & 2 deletions
20
EfCore.NamingConverter.Tests/Conventions/IndexNameConventionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
namespace EfCore.NamingConverter.Tests.Conventions | ||
using EfCore.NamingConverter.Conventions; | ||
using EfCore.NamingConverter.Converters; | ||
using EfCore.NamingConverter.Tests.TestCases; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EfCore.NamingConverter.Tests.Conventions | ||
{ | ||
public class IndexNameConventionTest | ||
{ | ||
// TDDO: The test is not implemented yet | ||
[Fact] | ||
public void ProcessIndexAdded_UseSnakeCaseLower_ShouldReturnSnakeCaseLower() | ||
{ | ||
var convention = new IndexNameConvention(NameConverter.SnakeCaseLower); | ||
|
||
var entityType = MockBuilder.BuildEntityType(b => b.Entity<SomeEntity>().HasIndex(x => x.SomeProperty), convention); | ||
|
||
string? indexName = entityType.GetIndexes().Single()?.GetDatabaseName(); | ||
|
||
Assert.NotNull(indexName); | ||
Assert.Equal("ix_some_entity_some_property", indexName); | ||
} | ||
} | ||
} |
22 changes: 20 additions & 2 deletions
22
EfCore.NamingConverter.Tests/Conventions/KeyNameConventionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,25 @@ | ||
namespace EfCore.NamingConverter.Tests.Conventions | ||
using EfCore.NamingConverter.Conventions; | ||
using EfCore.NamingConverter.Converters; | ||
using EfCore.NamingConverter.Tests.TestCases; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Internal; | ||
|
||
namespace EfCore.NamingConverter.Tests.Conventions | ||
{ | ||
public class KeyNameConventionTest | ||
{ | ||
// TODO:The test is not implemented yet | ||
[Fact] | ||
public void ProcessKeyAdded_UseSnakeCaseLower_ShouldReturnSnakeCaseLower() | ||
{ | ||
var convention = new KeyNameConvention(NameConverter.SnakeCaseLower); | ||
var entityType = MockBuilder.BuildEntityType(b => b.Entity<SomeEntity>(), convention); | ||
var key = entityType.FindPrimaryKey(); | ||
|
||
Assert.NotNull(key); | ||
|
||
var keyName = key.GetName(); | ||
|
||
Assert.NotNull(keyName); | ||
} | ||
} | ||
} |
19 changes: 17 additions & 2 deletions
19
EfCore.NamingConverter.Tests/Conventions/TableNameConventionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
namespace EfCore.NamingConverter.Tests.Conventions | ||
using EfCore.NamingConverter.Conventions; | ||
using EfCore.NamingConverter.Converters; | ||
using EfCore.NamingConverter.Tests.TestCases; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace EfCore.NamingConverter.Tests.Conventions | ||
{ | ||
public class TableNameConventionTest | ||
{ | ||
// TODO:The test is not implemented yet | ||
[Fact] | ||
public void ProcessEntityTypeAdded_UseSnakeCaseLower_ShouldApplyTableNameConvention() | ||
{ | ||
// Arrange | ||
var convention = new TableNameConvention(NameConverter.SnakeCaseLower); | ||
var entityType = MockBuilder.BuildEntityType(b => b.Entity<SomeEntity>(), convention); | ||
// Act | ||
var tableName = entityType.GetTableName(); | ||
// Assert | ||
Assert.Equal("some_entity", tableName); | ||
} | ||
} | ||
} |
45 changes: 43 additions & 2 deletions
45
EfCore.NamingConverter.Tests/Conventions/ViewNameConventionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
namespace EfCore.NamingConverter.Tests.Conventions | ||
using EfCore.NamingConverter.Conventions; | ||
using EfCore.NamingConverter.Converters; | ||
using EfCore.NamingConverter.Tests.TestCases; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
|
||
namespace EfCore.NamingConverter.Tests.Conventions | ||
{ | ||
public class ViewNameConventionTest | ||
{ | ||
// TODO:The test is not implemented yet | ||
|
||
[Fact] | ||
public void ProcessEntityTypeAdded_UseSnakeCaseLower_ShouldApplyViewNameConvention() | ||
{ | ||
// Arrange | ||
var convention = new ViewNameConvention(NameConverter.SnakeCaseLower); | ||
|
||
var entityType = MockBuilder.BuildEntityType(b => b.Entity<SomeEntity>(e => | ||
{ | ||
e.ToView("some_entity_view"); | ||
}), convention); | ||
|
||
// Act | ||
var viewName = entityType.GetViewName(); | ||
|
||
// Assert | ||
Assert.Equal("some_entity_view", viewName); | ||
} | ||
|
||
[Fact] | ||
public void ProcessColumnTypeAdded_UseSnakeCaseLower_ShouldApplyViewNameColumnConvention() | ||
{ | ||
var convention = new ColumnNameConvention(NameConverter.SnakeCaseLower); | ||
var entityType = MockBuilder.BuildEntityType(b => b.Entity<SomeEntity>(e => | ||
{ | ||
e.ToView("SomeEntityView"); | ||
}), convention); | ||
|
||
var property = entityType.GetProperty(nameof(SomeEntity.SomeProperty)); | ||
|
||
var identifier = StoreObjectIdentifier.Create(entityType, StoreObjectType.View).GetValueOrDefault(); | ||
|
||
var columnName = property.GetColumnName(identifier); | ||
|
||
Assert.Equal("some_property", columnName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.