Skip to content

Commit

Permalink
Add tests to verify no collision
Browse files Browse the repository at this point in the history
  • Loading branch information
inputfalken committed Dec 27, 2024
1 parent 9c33742 commit a3e77fd
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 0 deletions.
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);
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);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace DynamoDBGenerator.SourceGenerator.Tests.Namespace;

public record SampleClass(int Property);

0 comments on commit a3e77fd

Please sign in to comment.