@@ -7,6 +7,7 @@ namespace DynamoDBGenerator.SourceGenerator.Tests.DynamoDBDocumentTests;
7
7
[ DynamoDBMarshaller ( EntityType = typeof ( SelfReferencingClass ) ) ]
8
8
[ DynamoDBMarshaller ( EntityType = typeof ( ClassWithOverriddenAttributeName ) ) ]
9
9
[ DynamoDBMarshaller ( EntityType = typeof ( InheritedClass ) ) ]
10
+ [ DynamoDBMarshaller ( EntityType = typeof ( DuplicatedNavigationProperties ) ) ]
10
11
public partial class ExpressionAttributeTrackerTests
11
12
{
12
13
[ Fact ]
@@ -85,6 +86,25 @@ public void SelfReference_AttributeNames_EnsureUniquness()
85
86
field1 . Should ( ) . Be ( "#Self.#Self.#Self.#Self.#Field1" ) ;
86
87
field2 . Should ( ) . Be ( "#Self.#Self.#Self.#Field2" ) ;
87
88
}
89
+ [ Fact ]
90
+ public void DuplicatedNavigationProperties_AttributeNames_EnsureUniquness ( )
91
+ {
92
+ var nametracker = DuplicatedNavigationPropertiesMarshaller . AttributeExpressionNameTracker ( ) ;
93
+ var field1 = nametracker . Person1 . CreatedAt ;
94
+ var field2 = nametracker . Person2 . CreatedAt ;
95
+
96
+ ( nametracker as IAttributeExpressionNameTracker )
97
+ . AccessedNames ( )
98
+ . Should ( )
99
+ . BeEquivalentTo ( new KeyValuePair < string , string > [ ] {
100
+ new KeyValuePair < string , string > ( "#CreatedAt" , "CreatedAt" ) ,
101
+ new KeyValuePair < string , string > ( "#Person1" , "Person1" ) ,
102
+ new KeyValuePair < string , string > ( "#Person2" , "Person2" )
103
+ } ) ;
104
+
105
+ field1 . Should ( ) . Be ( "#Self.#Self.#Self.#Self.#Field1" ) ;
106
+ field2 . Should ( ) . Be ( "#Self.#Self.#Self.#Field2" ) ;
107
+ }
88
108
89
109
[ Theory ]
90
110
[ InlineData ( 5 ) ]
@@ -218,6 +238,12 @@ public class ClassWithOverriddenAttributeName
218
238
public string Foo { get ; set ; } = null ! ;
219
239
}
220
240
241
+
242
+ public class DuplicatedNavigationProperties
243
+ {
244
+ public Person Person1 { get ; set ; } = null ! ;
245
+ public Person Person2 { get ; set ; } = null ! ;
246
+ }
221
247
public class SelfReferencingClass
222
248
{
223
249
public string Field1 { get ; set ; } = null ! ;
0 commit comments