-
Notifications
You must be signed in to change notification settings - Fork 13
/
Issue0017.cs
57 lines (46 loc) · 1.2 KB
/
Issue0017.cs
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
48
49
50
51
52
53
54
55
56
57
using Dahomey.Cbor.Attributes;
using Xunit;
namespace Dahomey.Cbor.Tests.Issues
{
public class Issue0017
{
private class Tree
{
public int age = 0;
[CborProperty("r")]
private readonly byte[] _r;
[CborProperty("s")]
private readonly byte[] _s;
[CborConstructor]
public Tree(byte[] r, byte[] s)
{
_r = r;
_s = s;
}
public byte[] GetR()
{
return _r;
}
public byte[] GetS()
{
return _s;
}
}
[Fact]
public void Test()
{
CborOptions.Default.Registry.ObjectMappingRegistry.Register<Tree>(om =>
{
om.AutoMap();
om.ClearMemberMappings();
om.MapMember(t => t.age);
});
const string hexBuffer = "A1636167650C";
Tree tree = Helper.Read<Tree>(hexBuffer);
Assert.NotNull(tree);
Assert.Equal(12, tree.age);
Assert.Null(tree.GetR());
Assert.Null(tree.GetS());
}
}
}