1
1
using Amazon . DynamoDBv2 . Model ;
2
2
using AutoFixture ;
3
+ using DynamoDBGenerator . Exceptions ;
3
4
using Dynatello . Builders ;
4
5
using FluentAssertions ;
5
6
@@ -16,6 +17,57 @@ static ToGetItemRequestTests()
16
17
GetCatByCompositeKeys = Cat . QueryWithCuteness . OnTable ( "TABLE" ) . ToGetRequestBuilder ( x => x . Id , x => x . HomeId ) ;
17
18
}
18
19
20
+ [ Fact ]
21
+ public void Build_Request_CompositeKeys_InvalidPartition ( )
22
+ {
23
+ var act = ( ) => Cat . QueryWithCuteness
24
+ . OnTable ( "TABLE" )
25
+ . ToGetRequestBuilder ( x => x . Name , x => x . HomeId )
26
+ . Build ( ( "" , Guid . Empty ) ) ;
27
+
28
+ act . Should ( )
29
+ . Throw < DynamoDBMarshallingException > ( )
30
+ . WithMessage ( "Value '*' from argument '*' is not convertable*" ) ;
31
+ }
32
+
33
+ [ Fact ]
34
+ public void Build_Request_CompositeKeys_InvalidRange ( )
35
+ {
36
+ var act = ( ) => Cat . QueryWithCuteness
37
+ . OnTable ( "TABLE" )
38
+ . ToGetRequestBuilder ( x => x . Id , x => x . Name )
39
+ . Build ( ( Guid . Empty , "" ) ) ;
40
+
41
+ act . Should ( )
42
+ . Throw < DynamoDBMarshallingException > ( )
43
+ . WithMessage ( "Value '*' from argument '*' is not convertable*" ) ;
44
+ }
45
+
46
+ [ Fact ]
47
+ public void Build_Request_CompositeKeys_InvalidPartitionAndRange ( )
48
+ {
49
+ var act = ( ) => Cat . QueryWithCuteness
50
+ . OnTable ( "TABLE" )
51
+ . ToGetRequestBuilder ( x => x . Cuteness , x => x . Name )
52
+ . Build ( ( 2.3 , "" ) ) ;
53
+
54
+ act . Should ( )
55
+ . Throw < DynamoDBMarshallingException > ( )
56
+ . WithMessage ( "Value '*' from argument '*' is not convertable*" ) ;
57
+ }
58
+
59
+ [ Fact ]
60
+ public void Build_Request_WithInvalidPartitionKey ( )
61
+ {
62
+ var act = ( ) => Cat . QueryWithCuteness
63
+ . OnTable ( "TABLE" )
64
+ . ToGetRequestBuilder ( x => x . Name )
65
+ . Build ( "TEST" ) ;
66
+ act . Should ( )
67
+ . Throw < DynamoDBMarshallingException > ( )
68
+ . WithMessage ( "Value '*' from argument '*' is not convertable*" ) ;
69
+ }
70
+
19
71
[ Fact ]
20
72
public void Build_Request_PartitionKeyOnly ( )
21
73
{
@@ -32,6 +84,7 @@ public void Build_Request_PartitionKeyOnly()
32
84
request . TableName . Should ( ) . Be ( "TABLE" ) ;
33
85
} ) ;
34
86
}
87
+
35
88
[ Fact ]
36
89
public void Build_Request_CompositeKeys ( )
37
90
{
@@ -43,8 +96,8 @@ public void Build_Request_CompositeKeys()
43
96
. Should ( )
44
97
. BeEquivalentTo ( new Dictionary < string , AttributeValue > ( )
45
98
{
46
- { nameof ( Cat . Id ) , new AttributeValue { S = keys . PartitionKey . ToString ( ) } } ,
47
- { nameof ( Cat . HomeId ) , new AttributeValue { S = keys . RangeKey . ToString ( ) } }
99
+ { nameof ( Cat . Id ) , new AttributeValue { S = keys . PartitionKey . ToString ( ) } } ,
100
+ { nameof ( Cat . HomeId ) , new AttributeValue { S = keys . RangeKey . ToString ( ) } }
48
101
}
49
102
) ;
50
103
0 commit comments