Skip to content

Commit 70239d6

Browse files
committed
Add MemberDocumentationTests
1 parent 338720d commit 70239d6

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System.Reflection;
2+
using System.Xml;
3+
4+
namespace BitzArt.XDoc.PlainText.Tests;
5+
6+
abstract class BaseClass
7+
{
8+
/// <summary>
9+
/// My comment
10+
/// </summary>
11+
public abstract int MyProperty { get; set; }
12+
}
13+
14+
class DemoClass : BaseClass
15+
{
16+
public override int MyProperty { get; set; }
17+
18+
public int MyOtherProperty { get; set; }
19+
}
20+
21+
public class MemberDocumentationTests
22+
{
23+
[Fact]
24+
public void GetInheritanceTarget_PropertyHasParent_ShouldReturnParentProperty()
25+
{
26+
var property = typeof(DemoClass).GetProperty(nameof(DemoClass.MyProperty));
27+
var xmlDocument = new XmlDocument();
28+
var textNode = xmlDocument.CreateTextNode("This is a test property.");
29+
30+
MemberDocumentation<PropertyInfo> memberDocumentation = new PropertyDocumentation(
31+
source: new XDoc(),
32+
property: property!,
33+
node: textNode);
34+
35+
var inheritanceTarget = memberDocumentation.GetInheritanceTarget();
36+
37+
Assert.NotNull(inheritanceTarget);
38+
}
39+
40+
[Fact]
41+
public void GetInheritanceTarget_PropertyHasNoParent_ShouldReturnNull()
42+
{
43+
var property = typeof(DemoClass).GetProperty(nameof(DemoClass.MyOtherProperty));
44+
var xmlDocument = new XmlDocument();
45+
var textNode = xmlDocument.CreateTextNode("This is a test property.");
46+
47+
MemberDocumentation<PropertyInfo> memberDocumentation = new PropertyDocumentation(
48+
source: new XDoc(),
49+
property: property!,
50+
node: textNode);
51+
52+
var inheritanceTarget = memberDocumentation.GetInheritanceTarget();
53+
54+
Assert.Null(inheritanceTarget);
55+
}
56+
}

0 commit comments

Comments
 (0)