Skip to content

Commit de647c3

Browse files
committed
Add another test to verify triangular access
1 parent c45cc1a commit de647c3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/DynamoDBGenerator.SourceGenerator.Tests/DynamoDBDocumentTests/ExpressionAttributeTrackerTests.cs

+26
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace DynamoDBGenerator.SourceGenerator.Tests.DynamoDBDocumentTests;
77
[DynamoDBMarshaller(EntityType = typeof(SelfReferencingClass))]
88
[DynamoDBMarshaller(EntityType = typeof(ClassWithOverriddenAttributeName))]
99
[DynamoDBMarshaller(EntityType = typeof(InheritedClass))]
10+
[DynamoDBMarshaller(EntityType = typeof(DuplicatedNavigationProperties))]
1011
public partial class ExpressionAttributeTrackerTests
1112
{
1213
[Fact]
@@ -85,6 +86,25 @@ public void SelfReference_AttributeNames_EnsureUniquness()
8586
field1.Should().Be("#Self.#Self.#Self.#Self.#Field1");
8687
field2.Should().Be("#Self.#Self.#Self.#Field2");
8788
}
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+
}
88108

89109
[Theory]
90110
[InlineData(5)]
@@ -218,6 +238,12 @@ public class ClassWithOverriddenAttributeName
218238
public string Foo { get; set; } = null!;
219239
}
220240

241+
242+
public class DuplicatedNavigationProperties
243+
{
244+
public Person Person1 { get; set; } = null!;
245+
public Person Person2 { get; set; } = null!;
246+
}
221247
public class SelfReferencingClass
222248
{
223249
public string Field1 { get; set; } = null!;

0 commit comments

Comments
 (0)