Skip to content

Commit 085ed35

Browse files
committed
Add test to avoid bug
1 parent e073254 commit 085ed35

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

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

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using DynamoDBGenerator.Attributes;
22
namespace DynamoDBGenerator.SourceGenerator.Tests.DynamoDBDocumentTests;
33

4+
45
[DynamoDBMarshaller(EntityType = typeof(Person), ArgumentType = typeof((string firstName, DateTime timeStamp)), AccessName = "PersonWithTupleArgument")]
56
[DynamoDBMarshaller(EntityType = typeof(Person))]
67
[DynamoDBMarshaller(EntityType = typeof(SelfReferencingClass))]
@@ -22,12 +23,12 @@ public void PersonWithTupleArgument_AccessingRootExpressionAttributeValue_Should
2223
{
2324
var valueTracker = PersonWithTupleArgument.AttributeExpressionValueTracker();
2425
var tracker = valueTracker as IAttributeExpressionValueTracker<(string firstName, DateTime timeStamp)>;
25-
26+
2627
var act = () => valueTracker.ToString();
2728
act.Should().NotThrow();
2829
tracker.ToString().Should().Be(":p1");
2930
}
30-
31+
3132
[Fact]
3233
public void PersonWithTupleArgument_AccessingNestedExpressionAttributeName_ShouldNotThrow()
3334
{
@@ -38,7 +39,7 @@ public void PersonWithTupleArgument_AccessingNestedExpressionAttributeName_Shoul
3839
act.Should().NotThrow();
3940
nameTracker.Address.ToString().Should().Be("#Address");
4041
}
41-
42+
4243
[Fact]
4344
public void PersonWithTupleArgument_Tuple_CanBeParameterized()
4445
{
@@ -64,6 +65,24 @@ public void PersonWithTupleArgument_Tuple_CanBeParameterized()
6465
});
6566
}
6667

68+
69+
[Fact]
70+
public void SelfReference_AttributeNames_EnsureUniquness()
71+
{
72+
var nametracker = SelfReferencingClassMarshaller.AttributeExpressionNameTracker();
73+
var field1 = nametracker.Self.Self.Self.Self.Field1;
74+
var field2 = nametracker.Self.Self.Self.Field2;
75+
76+
(nametracker as IAttributeExpressionNameTracker)
77+
.AccessedNames()
78+
.Should()
79+
.BeEquivalentTo(new KeyValuePair<string, string>[] {
80+
new KeyValuePair<string ,string>("#Self", "Self"),
81+
new KeyValuePair<string ,string>("#Field1", "Field1"),
82+
new KeyValuePair<string ,string>("#Field2", "Field2")
83+
});
84+
}
85+
6786
[Theory]
6887
[InlineData(5)]
6988
[InlineData(10)]
@@ -187,7 +206,7 @@ int count
187206

188207
public class InheritedClass : ClassWithOverriddenAttributeName
189208
{
190-
209+
191210
}
192211

193212
public class ClassWithOverriddenAttributeName

0 commit comments

Comments
 (0)