File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ <Project Sdk =" Microsoft.NET.Sdk" >
2
+
3
+ <PropertyGroup >
4
+ <TargetFramework >net6.0</TargetFramework >
5
+ <Nullable >enable</Nullable >
6
+
7
+ <IsPackable >false</IsPackable >
8
+ </PropertyGroup >
9
+
10
+ <ItemGroup >
11
+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 16.11.0" />
12
+ <PackageReference Include =" NUnit" Version =" 3.13.2" />
13
+ <PackageReference Include =" NUnit3TestAdapter" Version =" 4.0.0" />
14
+ <PackageReference Include =" coverlet.collector" Version =" 3.1.0" />
15
+ </ItemGroup >
16
+
17
+ </Project >
Original file line number Diff line number Diff line change
1
+ using System . Text . RegularExpressions ;
2
+ using NUnit . Framework ;
3
+
4
+ namespace TestProject ;
5
+
6
+ public class Tests
7
+ {
8
+ private static readonly Regex tokensRegex = new Regex ( @"\{[\w\-_\+\d]+\}" ) ;
9
+
10
+ [ SetUp ]
11
+ public void Setup ( )
12
+ {
13
+ }
14
+
15
+ [ Test ]
16
+ public void Test1 ( )
17
+ {
18
+ Assert . Pass ( ) ;
19
+ }
20
+
21
+ [ Test ]
22
+ public void TestToken ( )
23
+ {
24
+ const string tokenStr = "{days1}我{parent_id}的上级: {days} {day+-s1}" ;
25
+ var matches = tokensRegex . Matches ( tokenStr ) ;
26
+ Assert . AreEqual ( 4 , matches . Count ) ;
27
+ Assert . AreEqual ( "{days1}" , matches [ 0 ] . Value ) ;
28
+ Assert . AreEqual ( "{parent_id}" , matches [ 1 ] . Value ) ;
29
+ Assert . AreEqual ( "{days}" , matches [ 2 ] . Value ) ;
30
+ Assert . AreEqual ( "{day+-s1}" , matches [ 3 ] . Value ) ;
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments