Skip to content

Commit e019a7b

Browse files
committed
Add tests to verify primitive arguments
1 parent 154302b commit e019a7b

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,48 @@
11
using Amazon.DynamoDBv2.Model;
22
using DynamoDBGenerator.Attributes;
3+
using DynamoDBGenerator.Extensions;
34

45
namespace DynamoDBGenerator.SourceGenerator.Tests.DynamoDBDocumentTests;
56

6-
[DynamoDBMarshaller(typeof((Guid, Guid)), PropertyName = "PrimitiveArgument", ArgumentType = typeof(string))]
7+
[DynamoDBMarshaller(typeof((Guid, Guid)), PropertyName = "STRING", ArgumentType = typeof(string))]
8+
[DynamoDBMarshaller(typeof((Guid, Guid)), PropertyName = "GUID", ArgumentType = typeof(Guid))]
9+
[DynamoDBMarshaller(typeof((Guid, Guid)), PropertyName = "INT", ArgumentType = typeof(int))]
710
public partial class PrimitiveArgumentTests
811
{
912
[Fact]
10-
public void ExpressionValueTracker_String_ShouldBeExpandedCorrectly()
13+
public void ExpressionValueTracker_STRING_ShouldBeExpandedCorrectly()
1114
{
12-
IAttributeExpressionValueTracker<string> valueTracker = PrimitiveArgument.AttributeExpressionValueTracker();
15+
IAttributeExpressionValueTracker<string> valueTracker = STRING.AttributeExpressionValueTracker();
1316
valueTracker.ToString().Should().Be(":p1");
1417

1518
valueTracker.AccessedValues("hello").Should().BeEquivalentTo(new Dictionary<string, AttributeValue>
1619
{
1720
{ ":p1", new AttributeValue { S = "hello" } }
1821
});
1922
}
23+
24+
[Fact]
25+
public void ExpressionValueTracker_INT_ShouldBeExpandedCorrectly()
26+
{
27+
IAttributeExpressionValueTracker<int> valueTracker = INT.AttributeExpressionValueTracker();
28+
valueTracker.ToString().Should().Be(":p1");
29+
30+
valueTracker.AccessedValues(2).Should().BeEquivalentTo(new Dictionary<string, AttributeValue>
31+
{
32+
{ ":p1", new AttributeValue { N = "2" } }
33+
});
34+
}
35+
36+
[Fact]
37+
public void ExpressionValueTracker_GUID_ShouldBeExpandedCorrectly()
38+
{
39+
IAttributeExpressionValueTracker<Guid> valueTracker = GUID.AttributeExpressionValueTracker();
40+
valueTracker.ToString().Should().Be(":p1");
41+
42+
var guid = Guid.NewGuid();
43+
valueTracker.AccessedValues(guid).Should().BeEquivalentTo(new Dictionary<string, AttributeValue>
44+
{
45+
{ ":p1", new AttributeValue { S = guid.ToString() } }
46+
});
47+
}
2048
}

0 commit comments

Comments
 (0)