forked from aljones/EFCore.SqlServer.HierarchyId
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SqlServerHierarchyIdTypeMappingSourcePlugin don't work correctly when ClrType is null
- Loading branch information
1 parent
f269397
commit 0d2cb87
Showing
2 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.SqlServer.Storage; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Xunit; | ||
|
||
namespace Microsoft.EntityFrameworkCore.SqlServer | ||
{ | ||
public class TypeMappingTests | ||
{ | ||
[Fact] | ||
public void Maps_int_column() | ||
{ | ||
var mapping = CreateMapper().FindMapping( | ||
new RelationalTypeMappingInfo( | ||
storeTypeName: "int", | ||
storeTypeNameBase: "int", | ||
unicode: null, | ||
size: null, | ||
precision: null, | ||
scale: null)); | ||
|
||
Assert.Null(mapping); | ||
} | ||
|
||
[Fact] | ||
public void Maps_hierarchyid_column() | ||
{ | ||
var mapping = CreateMapper().FindMapping( | ||
new RelationalTypeMappingInfo( | ||
storeTypeName: SqlServerHierarchyIdTypeMappingSourcePlugin.SqlServerTypeName, | ||
storeTypeNameBase: SqlServerHierarchyIdTypeMappingSourcePlugin.SqlServerTypeName, | ||
unicode: null, | ||
size: null, | ||
precision: null, | ||
scale: null)); | ||
|
||
AssertMapping<HierarchyId>(mapping); | ||
} | ||
|
||
private static void AssertMapping<T>( | ||
RelationalTypeMapping mapping) | ||
{ | ||
AssertMapping(typeof(T), mapping); | ||
} | ||
|
||
private static void AssertMapping( | ||
Type type, | ||
RelationalTypeMapping mapping) | ||
{ | ||
Assert.Same(type, mapping.ClrType); | ||
} | ||
|
||
private static IRelationalTypeMappingSourcePlugin CreateMapper() | ||
=> new SqlServerHierarchyIdTypeMappingSourcePlugin(); | ||
} | ||
} |
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