forked from stryker-mutator/stryker-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoslynHelperTests.cs
More file actions
36 lines (32 loc) · 1.08 KB
/
Copy pathRoslynHelperTests.cs
File metadata and controls
36 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
using Stryker.Core.Helpers;
namespace Stryker.Core.UnitTest.Helpers;
[TestClass]
public class RoslynHelperTests : TestBase
{
[TestMethod]
[DataRow("s is { Length: > 0 } region")]
[DataRow("s is var captured")]
[DataRow("s is int n")]
public void ContainsDeclarationsShouldDetectPatternDesignations(string expression)
{
SyntaxFactory.ParseExpression(expression).ContainsDeclarations().ShouldBeTrue();
}
[TestMethod]
public void ContainsDeclarationsShouldDetectOutVarDeclaration()
{
SyntaxFactory.ParseExpression("int.TryParse(s, out var value)")
.ContainsDeclarations().ShouldBeTrue();
}
[TestMethod]
[DataRow("s.Length > 0")]
[DataRow("s is [_, _]")]
[DataRow("(a, b)")]
public void ContainsDeclarationsShouldReturnFalseWithoutDeclarations(string expression)
{
SyntaxFactory.ParseExpression(expression).ContainsDeclarations().ShouldBeFalse();
}
}