Skip to content

Commit da22b56

Browse files
author
Michael Catanzariti
committed
Added test for Bug: required parameterless constructor #35
1 parent 632349b commit da22b56

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Xunit;
2+
3+
namespace Dahomey.Cbor.Tests.Issues
4+
{
5+
public class Issue0035
6+
{
7+
public class Result<T>
8+
{
9+
public T Data { get; set; }
10+
11+
public Result(T data)
12+
{
13+
Data = data;
14+
}
15+
}
16+
17+
[Fact]
18+
void TestRead()
19+
{
20+
const string hexBuffer = "A164446174616474657374";
21+
Result<string> result = Helper.Read<Result<string>>(hexBuffer);
22+
23+
Assert.NotNull(result);
24+
Assert.Equal("test", result.Data);
25+
}
26+
27+
[Fact]
28+
void TestWrite()
29+
{
30+
Result<string> result = new Result<string>("test");
31+
string hexEncoded = null;
32+
var ex = Record.Exception(() =>
33+
{
34+
hexEncoded = Helper.Write(result);
35+
});
36+
Assert.Null(ex);
37+
Assert.NotNull(hexEncoded);
38+
Assert.Equal("A164446174616474657374", hexEncoded);
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)