File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments