File tree Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 49
49
<LogicalName >Strings.resx.resources</LogicalName >
50
50
</EmbeddedResource >
51
51
</ItemGroup >
52
- <ItemGroup >
53
- <Compile Remove =" Identity.cs" />
54
- </ItemGroup >
55
52
<ItemGroup >
56
53
<Compile Condition =" '$(EnableDefaultCompileItems)' == 'true' " Update =" Resources\ExceptionMessages.Designer.cs" >
57
54
<DependentUpon >ExceptionMessages.resx</DependentUpon >
63
60
<ItemGroup >
64
61
<Folder Include =" Resources\" />
65
62
</ItemGroup >
66
- <ItemGroup >
67
- <None Include =" Identity.cs" Condition =" '$(EnableDefaultCompileItems)' == 'true' " />
68
- </ItemGroup >
69
63
</Project >
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public static class Identity
37
37
{
38
38
static readonly IGetsIdentityType identityTypeProvider = new IdentityTypeProvider ( ) ;
39
39
static readonly ICreatesIdentity identityFactory = new IdentityFactory ( ) ;
40
- static readonly IUpCastsIdentity caster = new IdentityCaster ( ) ;
40
+ static readonly ICastsIdentityType caster = new IdentityTypeCaster ( ) ;
41
41
static readonly IParsesIdentity parser = new IdentityParser ( ) ;
42
42
43
43
/// <summary>
@@ -69,7 +69,7 @@ public static IIdentity<TEntity> Parse<TEntity>(object value) where TEntity : IE
69
69
/// <param name="identity">The identity to convert to a different entity type.</param>
70
70
/// <typeparam name="TCast">The desired entity type.</typeparam>
71
71
/// <exception cref="InvalidCastException">If the <paramref name="identity"/> is not suitable for the entity type <typeparamref name="TCast"/>.</exception>
72
- public static IIdentity < TCast > Cast < TCast > ( this IIdentity identity )
72
+ public static IIdentity < TCast > Cast < TCast > ( this IIdentity identity ) where TCast : IEntity
73
73
=> caster . CastIdentity < TCast > ( identity ) ;
74
74
}
75
75
}
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ public void Equals_returns_false_for_two_identities_with_incompatible_entity_typ
37
37
var identity2 = new Identity < long , Person > ( 5 ) ;
38
38
Assert . That ( identity1 . Equals ( identity2 ) , Is . False ) ;
39
39
}
40
+
40
41
[ Test , AutoMoqData ]
41
42
public void Equals_operator_returns_true_for_two_equal_identities ( )
42
43
{
@@ -69,6 +70,27 @@ public void Equals_operator_returns_false_for_two_identities_with_incompatible_e
69
70
Assert . That ( identity1 == identity2 , Is . False ) ;
70
71
}
71
72
73
+ [ Test , AutoMoqData ]
74
+ public void Create_creates_identity_with_correct_value ( )
75
+ {
76
+ var identity = Identity . Create < Cat > ( 5 ) ;
77
+ Assert . That ( identity . Value , Is . EqualTo ( 5 ) ) ;
78
+ }
79
+
80
+ [ Test , AutoMoqData ]
81
+ public void Parse_returns_identity_with_correct_value ( )
82
+ {
83
+ var identity = Identity . Parse < Cat > ( "66" ) ;
84
+ Assert . That ( identity . Value , Is . EqualTo ( 66 ) ) ;
85
+ }
86
+
87
+ [ Test , AutoMoqData ]
88
+ public void Cast_returns_appropriate_identity ( )
89
+ {
90
+ var identity = new Identity < long , Animal > ( 5 ) ;
91
+ Assert . That ( ( ) => Identity . Cast < Cat > ( identity ) . Value , Is . EqualTo ( 5 ) ) ;
92
+ }
93
+
72
94
[ Test , AutoMoqData ]
73
95
public void GetValueAsString_returns_correct_value ( )
74
96
{
You can’t perform that action at this time.
0 commit comments