Skip to content

Commit a94fe78

Browse files
author
齐天大胖子
authored
add test about yaml comments.
add a xunit test .cs file about yaml comments. it`s just an easy comment above the property when Serialize(*).
1 parent 37eb8d4 commit a94fe78

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Xunit;
2+
using Xunit.Abstractions;
3+
using YamlDotNet.Serialization;
4+
5+
namespace YamlDotNet.Test.Serialization
6+
{
7+
public class YamlCommentTests
8+
{
9+
protected readonly ITestOutputHelper Output;
10+
public YamlCommentTests(ITestOutputHelper helper)
11+
{
12+
Output = helper;
13+
}
14+
15+
[Fact]
16+
public void SerializationWithComment()
17+
{
18+
var person = new Person();
19+
person.Name = "PandaTea";
20+
person.Age = 100;
21+
person.Sex = "male";
22+
23+
Serializer serializer = new Serializer();
24+
string result = serializer.Serialize(person);
25+
26+
Output.WriteLine(result);
27+
}
28+
29+
class Person
30+
{
31+
[YamlMember(Description = "this is a yaml comment about name property")]
32+
public string Name { get; set; }
33+
[YamlMember(Description = "this is age")]
34+
public int Age { get; set; }
35+
[YamlMember(Description = "male or female")]
36+
public string Sex { get; set; }
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)