-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c33742
commit a3e77fd
Showing
3 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
tests/DynamoDBGenerator.SourceGenerator.Tests/Namespace/A/NamespaceATests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using Amazon.DynamoDBv2.Model; | ||
using DynamoDBGenerator.Attributes; | ||
|
||
namespace DynamoDBGenerator.SourceGenerator.Tests.Namespace.A; | ||
|
||
public class NamespaceATests | ||
{ | ||
[Fact] | ||
public void Verify_Correct_NameType() | ||
{ | ||
Container.ContainerMarshaller | ||
.AttributeExpressionNameTracker() | ||
.Should() | ||
.BeOfType<A.Container.ContainerNames>(); | ||
|
||
Container.ContainerMarshaller | ||
.AttributeExpressionNameTracker() | ||
.PropertyA | ||
.Should() | ||
.BeOfType<A.Container.SampleClassNames>(); | ||
} | ||
|
||
[Fact] | ||
public void Verify_Correct_ValueType() | ||
{ | ||
Container.ContainerMarshaller | ||
.AttributeExpressionValueTracker() | ||
.Should() | ||
.BeOfType<A.Container.ContainerValues>(); | ||
|
||
Container.ContainerMarshaller | ||
.AttributeExpressionValueTracker() | ||
.PropertyA | ||
.Should() | ||
.BeOfType<A.Container.SampleClassValues>(); | ||
} | ||
|
||
[Fact] | ||
public void Unmarshall() | ||
{ | ||
Container.ContainerMarshaller | ||
.Unmarshall(new Dictionary<string, AttributeValue> | ||
{ | ||
{ | ||
nameof(Container.PropertyA), | ||
new AttributeValue | ||
{ | ||
M = new Dictionary<string, AttributeValue> | ||
{ { nameof(Container.PropertyA.Property), new AttributeValue { N = "2" } } } | ||
} | ||
} | ||
}) | ||
.Should() | ||
.BeEquivalentTo(new Container(new SampleClass(2))); | ||
} | ||
|
||
[Fact] | ||
public void Marshall() | ||
{ | ||
Container.ContainerMarshaller | ||
.Marshall(new Container(new SampleClass(2))) | ||
.Should() | ||
.BeEquivalentTo(new Dictionary<string, AttributeValue> | ||
{ | ||
{ | ||
nameof(Container.PropertyA), | ||
new AttributeValue | ||
{ | ||
M = new Dictionary<string, AttributeValue> | ||
{ { nameof(Container.PropertyA.Property), new AttributeValue { N = "2" } } } | ||
} | ||
} | ||
} | ||
); | ||
} | ||
} | ||
|
||
[DynamoDBMarshaller] | ||
public partial record Container(SampleClass PropertyA); |
80 changes: 80 additions & 0 deletions
80
tests/DynamoDBGenerator.SourceGenerator.Tests/Namespace/B/NamespaceBTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using Amazon.DynamoDBv2.Model; | ||
using DynamoDBGenerator.Attributes; | ||
|
||
namespace DynamoDBGenerator.SourceGenerator.Tests.Namespace.B; | ||
|
||
public class NamespaceBTests | ||
{ | ||
|
||
[Fact] | ||
public void Verify_Correct_NameType() | ||
{ | ||
Container.ContainerMarshaller | ||
.AttributeExpressionNameTracker() | ||
.Should() | ||
.BeOfType<B.Container.ContainerNames>(); | ||
|
||
Container.ContainerMarshaller | ||
.AttributeExpressionNameTracker() | ||
.PropertyB | ||
.Should() | ||
.BeOfType<B.Container.SampleClassNames>(); | ||
} | ||
|
||
[Fact] | ||
public void Verify_Correct_ValueType() | ||
{ | ||
Container.ContainerMarshaller | ||
.AttributeExpressionValueTracker() | ||
.Should() | ||
.BeOfType<B.Container.ContainerValues>(); | ||
|
||
Container.ContainerMarshaller | ||
.AttributeExpressionValueTracker() | ||
.PropertyB | ||
.Should() | ||
.BeOfType<B.Container.SampleClassValues>(); | ||
} | ||
|
||
[Fact] | ||
public void Unmarshall() | ||
{ | ||
Container.ContainerMarshaller | ||
.Unmarshall(new Dictionary<string, AttributeValue> | ||
{ | ||
{ | ||
nameof(Container.PropertyB), | ||
new AttributeValue | ||
{ | ||
M = new Dictionary<string, AttributeValue> | ||
{ { nameof(Container.PropertyB.Property), new AttributeValue { N = "2" } } } | ||
} | ||
} | ||
}) | ||
.Should() | ||
.BeEquivalentTo(new Container(new SampleClass(2))); | ||
} | ||
|
||
[Fact] | ||
public void Marshall() | ||
{ | ||
Container.ContainerMarshaller | ||
.Marshall(new Container(new SampleClass(2))) | ||
.Should() | ||
.BeEquivalentTo(new Dictionary<string, AttributeValue> | ||
{ | ||
{ | ||
nameof(Container.PropertyB), | ||
new AttributeValue | ||
{ | ||
M = new Dictionary<string, AttributeValue> | ||
{ { nameof(Container.PropertyB.Property), new AttributeValue { N = "2" } } } | ||
} | ||
} | ||
} | ||
); | ||
} | ||
} | ||
|
||
[DynamoDBMarshaller] | ||
public partial record Container(SampleClass PropertyB); |
3 changes: 3 additions & 0 deletions
3
tests/DynamoDBGenerator.SourceGenerator.Tests/Namespace/SampleClass.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace DynamoDBGenerator.SourceGenerator.Tests.Namespace; | ||
|
||
public record SampleClass(int Property); |