59
59
//* only do so under a license that complies with this license.
60
60
//**********************************************************************
61
61
using System . Collections . Generic ;
62
+ using System . Linq ;
63
+ using System . Xml ;
62
64
using Xunit ;
65
+ using Xunit . Extensions ;
63
66
using Xunit . Sdk ;
64
67
65
68
namespace LibGit2Sharp . Tests . TestHelpers
@@ -68,24 +71,64 @@ class SkippableFactAttribute : FactAttribute
68
71
{
69
72
protected override IEnumerable < ITestCommand > EnumerateTestCommands ( IMethodInfo method )
70
73
{
71
- yield return new SkippableTestCommand ( method ) ;
74
+ return base . EnumerateTestCommands ( method ) . Select ( SkippableTestCommand . Wrap ( method ) ) ;
72
75
}
76
+ }
77
+
78
+ class SkippableTheoryAttribute : TheoryAttribute
79
+ {
80
+ protected override IEnumerable < ITestCommand > EnumerateTestCommands ( IMethodInfo method )
81
+ {
82
+ return base . EnumerateTestCommands ( method ) . Select ( SkippableTestCommand . Wrap ( method ) ) ;
83
+ }
84
+ }
73
85
74
- class SkippableTestCommand : FactCommand
86
+ class SkippableTestCommand : ITestCommand
87
+ {
88
+ public static Func < ITestCommand , ITestCommand > Wrap ( IMethodInfo method )
75
89
{
76
- public SkippableTestCommand ( IMethodInfo method ) : base ( method ) { }
90
+ return c => new SkippableTestCommand ( method , c ) ;
91
+ }
77
92
78
- public override MethodResult Execute ( object testClass )
93
+ private readonly IMethodInfo method ;
94
+ private readonly ITestCommand inner ;
95
+
96
+ private SkippableTestCommand ( IMethodInfo method , ITestCommand inner )
97
+ {
98
+ this . method = method ;
99
+ this . inner = inner ;
100
+ }
101
+
102
+ public MethodResult Execute ( object testClass )
103
+ {
104
+ try
79
105
{
80
- try
81
- {
82
- return base . Execute ( testClass ) ;
83
- }
84
- catch ( SkipException e )
85
- {
86
- return new SkipResult ( testMethod , DisplayName , e . Reason ) ;
87
- }
106
+ return inner . Execute ( testClass ) ;
88
107
}
108
+ catch ( SkipException e )
109
+ {
110
+ return new SkipResult ( method , DisplayName , e . Reason ) ;
111
+ }
112
+ }
113
+
114
+ public XmlNode ToStartXml ( )
115
+ {
116
+ return inner . ToStartXml ( ) ;
117
+ }
118
+
119
+ public string DisplayName
120
+ {
121
+ get { return inner . DisplayName ; }
122
+ }
123
+
124
+ public bool ShouldCreateInstance
125
+ {
126
+ get { return inner . ShouldCreateInstance ; }
127
+ }
128
+
129
+ public int Timeout
130
+ {
131
+ get { return inner . Timeout ; }
89
132
}
90
133
}
91
134
@@ -96,6 +139,6 @@ public SkipException(string reason)
96
139
Reason = reason ;
97
140
}
98
141
99
- public string Reason { get ; set ; }
142
+ public string Reason { get ; private set ; }
100
143
}
101
144
}
0 commit comments