Skip to content

Commit bf15e58

Browse files
committed
add stack trace unit tests
1 parent 58e8209 commit bf15e58

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Reflection;
2+
using System.Text.RegularExpressions;
3+
using Editor;
4+
5+
namespace TestEditor;
6+
7+
[TestClass]
8+
public class StackTraceTests
9+
{
10+
[TestMethod]
11+
[DataRow( @"at Example.Foo() in C:\sbox\Source.cs:line 123", true )]
12+
[DataRow( @"cat Example.Foo() in C:\sbox\Source.cs:line 123", false )]
13+
[DataRow( @"at Error in something in C:\sbox\Source.cs:line 123", true )]
14+
public void DefaultStackLine( string line, bool expectMatch )
15+
{
16+
var isMatch = GetDefaultStackLineHandlerRegex().Match( line );
17+
18+
Assert.AreEqual( expectMatch, isMatch.Success );
19+
}
20+
21+
private Regex GetDefaultStackLineHandlerRegex()
22+
{
23+
var method = typeof( StackTraceProperty ).GetMethod( nameof( StackTraceProperty.DefaultStackLineHandler ), BindingFlags.Static | BindingFlags.Public )!;
24+
25+
return new Regex( method.GetCustomAttribute<StackLineHandlerAttribute>()!.Regex );
26+
}
27+
}

0 commit comments

Comments
 (0)