-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarshalAsserter.cs
More file actions
47 lines (39 loc) · 1.53 KB
/
MarshalAsserter.cs
File metadata and controls
47 lines (39 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using Amazon.DynamoDBv2.Model;
namespace DynamoDBGenerator.SourceGenerator.Tests.DynamoDBDocumentTests.Marshaller.Asserters;
public abstract class MarshalAsserter<T>
{
protected abstract IEnumerable<(T element, Dictionary<string, AttributeValue> attributeValues)> Arguments();
protected abstract T UnmarshallImplementation(Dictionary<string, AttributeValue> attributeValues);
protected abstract Dictionary<string, AttributeValue> MarshallImplementation(T element);
[Fact]
public void Marshall()
{
Arguments().Should()
.AllSatisfy(x => MarshallImplementation(x.element).Should().BeEquivalentTo(x.attributeValues));
}
[Fact]
public void Unmarshall()
{
Arguments().Should()
.AllSatisfy(x => UnmarshallImplementation(x.attributeValues).Should().BeEquivalentTo(x.element));
}
[Fact]
public void Marshall_IsEquivalentTo_UnmarshallResult()
{
Arguments().Should().AllSatisfy(x =>
UnmarshallImplementation(MarshallImplementation(x.element)).Should().BeEquivalentTo(x.element));
}
[Fact]
public void UnMarshall_IsEquivalentTo_MarshallResult()
{
Arguments().Should().AllSatisfy(x =>
MarshallImplementation(UnmarshallImplementation(x.attributeValues)).Should()
.BeEquivalentTo(x.attributeValues));
}
[Fact]
public void Unmarshall_NullAttributeValues_ShouldThrow()
{
var act = () => UnmarshallImplementation(null!);
act.Should().Throw<ArgumentNullException>();
}
}