Skip to content

Commit c181e46

Browse files
committed
Refact project, tests
1 parent 8e4e7cd commit c181e46

40 files changed

+140
-140
lines changed

src/SimpleStateMachine.StructuralSearch.Sandbox/ParsingConfiguration.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/SimpleStateMachine.StructuralSearch.Sandbox/Program.cs

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,14 @@ internal static class Program
66
{
77
static void Main(string[] args)
88
{
9-
10-
var template1 =
11-
"if($condition$)\n" +
12-
"return $value1$;\n" +
13-
"else\n" +
14-
"return $value2$;";
15-
16-
var example1 =
17-
"if((value) = (5))\n" +
18-
"return \"Result1\";\n" +
19-
"else\n" +
20-
"return \"Result2\";";
21-
22-
var template2 =
23-
"if($var$ $sign$ null)\n" +
24-
"{\n" +
25-
"$var$ = $value$;\n" +
26-
"}";
27-
28-
var example2 =
29-
"if(temp == null)\n" +
30-
"{\n" +
31-
"temp = new List<string>();\n" +
32-
"}";
33-
34-
var template3 =
35-
"if($value1$ $sign$ null)\n" +
36-
"{\n" +
37-
"$var$ = $value1$;\n" +
38-
"}\n" +
39-
"else\n" +
40-
"{\n" +
41-
"$var$ = $value2$;\n" +
42-
"}";
43-
44-
var testTempalte = "if($test$)";
45-
var testText = "if((value1)&&(value2))";
46-
var testTextForMatch = "fdjkfnafdjankfjnafkajndaif((value1)&&(value2))";
47-
var testTempalte2 = "return $value$;";
48-
var testText2 = "return 125;;;;";
49-
50-
var parser = FindTemplateParser.ParseTemplate(template2);
51-
var result = parser.ParseOrThrow(example2);
9+
// var testTempalte = "if($test$)";
10+
// var testText = "if((value1)&&(value2))";
11+
// var testTextForMatch = "fdjkfnafdjankfjnafkajndaif((value1)&&(value2))";
12+
// var testTempalte2 = "return $value$;";
13+
// var testText2 = "return 125;;;;";
14+
//
15+
// var parser = StructuralSearch.ParseTemplate(template3);
16+
// var result = parser.ParseOrThrow(example3);
5217
}
5318
}
5419
}

src/SimpleStateMachine.StructuralSearch.Sandbox/SimpleStateMachine.StructuralSearch.Sandbox.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
<PackageReference Include="Pidgin" Version="3.0.0" />
1313
</ItemGroup>
1414

15+
<ItemGroup>
16+
<ProjectReference Include="..\SimpleStateMachine.StructuralSearch\SimpleStateMachine.StructuralSearch.csproj" />
17+
</ItemGroup>
18+
1519
</Project>

src/SimpleStateMachine.StructuralSearch.Sandbox/StructuralSearch/StructuralSearch.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/SimpleStateMachine.StructuralSearch.Sandbox/TestParser.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.IO;
2+
using Pidgin;
3+
using Xunit;
4+
5+
namespace SimpleStateMachine.StructuralSearch.Tests
6+
{
7+
public class FindTemplateTests
8+
{
9+
[Theory]
10+
[InlineData("Templates/IfElseTemplate.txt")]
11+
[InlineData("Templates/IfValueIsNullTemplate.txt")]
12+
[InlineData("Templates/NestedParenthesisedTemplate.txt")]
13+
public void TemplateParsingShouldBeSuccess(string templatePath)
14+
{
15+
var templateStr = File.ReadAllText(templatePath);
16+
var template = StructuralSearch.ParseTemplate(templateStr);
17+
18+
Assert.NotNull(template);
19+
}
20+
21+
[Theory]
22+
[InlineData("Templates/IfElseTemplate.txt", "Sources/IfElseSource.txt")]
23+
[InlineData("Templates/IfValueIsNullTemplate.txt", "Templates/IfValueIsNullSource.txt")]
24+
[InlineData("Templates/NestedParenthesisedTemplate.txt", "Templates/NestedParenthesisedSource.txt")]
25+
public void SourceParsingBeTemplateShouldBeSuccess(string templatePath, string sourcePath)
26+
{
27+
var templateStr = File.ReadAllText(templatePath);
28+
var sourceStr = File.ReadAllText(templatePath);
29+
30+
var template = StructuralSearch.ParseTemplate(templateStr);
31+
var result = template.ParseOrThrow(sourceStr);
32+
33+
Assert.NotNull(template);
34+
Assert.NotNull(result);
35+
Assert.NotNull(result.Value);
36+
Assert.Equal(result.Lenght, sourceStr.Length);
37+
}
38+
}
39+
}

src/SimpleStateMachine.StructuralSearch.Tests/SimpleStateMachine.StructuralSearch.Tests.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
55
<Nullable>enable</Nullable>
6-
76
<IsPackable>false</IsPackable>
8-
97
<LangVersion>9</LangVersion>
108
</PropertyGroup>
119

@@ -26,4 +24,13 @@
2624
<ProjectReference Include="..\SimpleStateMachine.StructuralSearch\SimpleStateMachine.StructuralSearch.csproj" />
2725
</ItemGroup>
2826

27+
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
28+
<Content Include="Sources\*.txt">
29+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
30+
</Content>
31+
<Content Include="Templates\*.txt">
32+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
33+
</Content>
34+
</ItemGroup>
35+
2936
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if(temp = 125)
2+
{
3+
test = 12;
4+
}
5+
else
6+
{
7+
test = 15;
8+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if(temp == null)
2+
{
3+
temp = new List<string>();
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
((value1) && (value2))

0 commit comments

Comments
 (0)