Skip to content

Commit 3bd23f0

Browse files
Merge pull request #12 from SimpleStateMachine/dev2
Update packages, remove unused code, fix some tests, empty entity on parse null or empty string
2 parents b06e263 + 9b3653a commit 3bd23f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+524
-637
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Pidgin" Version="3.1.0" />
13-
<PackageReference Include="YamlDotNet" Version="11.2.1" />
12+
<PackageReference Include="Pidgin" Version="3.2.0" />
13+
<PackageReference Include="YamlDotNet" Version="12.0.2" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

src/SimpleStateMachine.StructuralSearch.Tests/ConfigurationFile/FullConfig.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Configurations:
22
# AssignmentNullUnionOperator
33
- FindTemplate: |-
4-
if($var$ $sign$ null)
4+
if ($var$ $sign$ null)
55
{
66
$var$ = $value$;
77
}
@@ -14,7 +14,7 @@
1414
# NullUnionOperator
1515

1616
- FindTemplate: |-
17-
if($value$ $sign$ null)
17+
if ($value$ $sign$ null)
1818
$var$ = $value2$;
1919
else
2020
$var$ = $value1$;
@@ -29,7 +29,7 @@
2929
# TernaryOperator
3030

3131
- FindTemplate: |-
32-
if($condition$)
32+
if ($condition$)
3333
return $value1$;
3434
else
3535
return $value2$;

src/SimpleStateMachine.StructuralSearch.Tests/ConfigurationFile/If.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Configurations:
2-
- FindTemplate: if($var1$ == $var2$)
2+
- FindTemplate: if ($var1$ == $var2$)
33
FindRules:
44
- $var1$ Is Var
55
- $var2$ is Var

src/SimpleStateMachine.StructuralSearch.Tests/ConfigurationFile/ShortConfig.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Configurations:
22
# AssignmentNullUnionOperator
33
- FindTemplate: |-
4-
if($var$ $sign$ null)
4+
if ($var$ $sign$ null)
55
{
66
$var$ = $value$;
77
}
@@ -13,7 +13,7 @@
1313
# NullUnionOperator
1414

1515
- FindTemplate: |-
16-
if($value$ $sign$ null)
16+
if ($value$ $sign$ null)
1717
$var$ = $value2$;
1818
else
1919
$var$ = $value1$;
@@ -28,7 +28,7 @@
2828
# TernaryOperator
2929

3030
- FindTemplate: |-
31-
if($condition$)
31+
if ($condition$)
3232
return $value1$;
3333
else
3434
return $value2$;

src/SimpleStateMachine.StructuralSearch.Tests/ConfigurationFileTests.cs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,35 @@
44
using SimpleStateMachine.StructuralSearch.Tests.Mock;
55
using Xunit;
66

7-
namespace SimpleStateMachine.StructuralSearch.Tests
7+
namespace SimpleStateMachine.StructuralSearch.Tests;
8+
9+
public static class ConfigurationFileParserTests
810
{
9-
public class ConfigurationFileParserTests
11+
[Theory]
12+
[InlineData("ConfigurationFile/ShortConfig.yml")]
13+
[InlineData("ConfigurationFile/FullConfig.yml")]
14+
public static void ConfigurationFileParsingShouldBeSuccess(string filePath)
1015
{
11-
[Theory]
12-
[InlineData("ConfigurationFile/ShortConfig.yml")]
13-
[InlineData("ConfigurationFile/FullConfig.yml")]
14-
public void ConfigurationFileParsingShouldBeSuccess(string filePath)
15-
{
16-
var cfg = YmlHelper.Parse(filePath);
17-
var mock = Mock();
18-
Assert.Equal(mock, cfg);
19-
}
16+
var cfg = YmlHelper.Parse(filePath);
17+
var mock = Mock();
18+
Assert.Equal(mock, cfg);
19+
}
2020

21-
private ConfigurationFile Mock()
22-
{
23-
var names = new[] { "AssignmentNullUnionOperator", "NullUnionOperator", "TernaryOperator"};
24-
25-
var configurationFile = new ConfigurationFile
26-
{
27-
Configurations = new List<Configuration>()
28-
};
29-
30-
foreach (var name in names)
31-
{
32-
var config = ConfigurationMock.GetConfigurationFromFiles(name);
33-
configurationFile.Configurations.Add(config);
34-
}
21+
private static ConfigurationFile Mock()
22+
{
23+
var names = new[] { "AssignmentNullUnionOperator", "NullUnionOperator", "TernaryOperator"};
24+
25+
var configurationFile = new ConfigurationFile
26+
(
27+
configurations: new List<Configuration>()
28+
);
3529

36-
return configurationFile;
30+
foreach (var name in names)
31+
{
32+
var config = ConfigurationMock.GetConfigurationFromFiles(name);
33+
configurationFile.Configurations.Add(config);
3734
}
35+
36+
return configurationFile;
3837
}
3938
}

src/SimpleStateMachine.StructuralSearch.Tests/ExamplesInput/Common.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ public int Method1()
66
{
77
var temp = 5;
88

9-
if(temp == 6)
9+
if (temp == 6)
1010
return 7;
1111
else
1212
return 8;
1313
}
1414

15-
public void Method2()
15+
public static void Method2()
1616
{
1717
int? result;
1818
int? temp1 = 5;
1919
int? temp2 = 5;
20-
if(temp1 is null)
20+
if (temp1 is null)
2121
result = temp2;
2222
else
2323
result = temp1;
2424
}
2525

26-
public void Method3()
26+
public static void Method3()
2727
{
2828
int result;
2929
int? temp1 = 5;
3030
int? temp2 = 5;
31-
if(temp1 is null)
31+
if (temp1 is null)
3232
result = temp2.Value;
3333
else
3434
result = temp1.Value;

src/SimpleStateMachine.StructuralSearch.Tests/ExamplesInput/Common2.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ public int Method1()
99
return temp == 6 ? 7 : 8;
1010
}
1111

12-
public void Method2()
12+
public static void Method2()
1313
{
1414
int? result;
1515
int? temp1 = 5;
1616
int? temp2 = 5;
1717
result = temp1 ?? temp2;
1818
}
1919

20-
public void Method3()
20+
public static void Method3()
2121
{
2222
int result;
2323
int? temp1 = 5;
Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,28 @@
1-
namespace SimpleStateMachine.StructuralSearch.Tests.ExamplesInput;
1+
namespace SimpleStateMachine.StructuralSearch.Tests.Examples;
22

33
public class NullUnionOperator
44
{
5-
public void Test1()
5+
public static void Test1()
66
{
77
int? result;
88
int? temp1 = 5;
99
int? temp2 = 5;
1010

11-
if(temp1 is null)
11+
if (temp1 is null)
1212
result = temp2;
1313
else
1414
result = temp1;
1515
}
1616

17-
public void Test2()
17+
public static void Test2()
1818
{
1919

2020
int? result;
2121
int? temp1 = 6;
2222
int? temp2 = 7;
23-
if(temp1 is not null)
23+
if (temp1 is not null)
2424
result = temp2;
2525
else
2626
result = temp1;
2727
}
28-
29-
public int Test3()
30-
{
31-
int? temp3 = 5;
32-
33-
if(temp3 is null)
34-
return 7;
35-
else if (temp3 == 8)
36-
return 9;
37-
else
38-
return 10;
39-
}
4028
}

src/SimpleStateMachine.StructuralSearch.Tests/ExamplesInput/TernaryOperator.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
namespace SimpleStateMachine.StructuralSearch.Tests.ExamplesInput
1+
namespace SimpleStateMachine.StructuralSearch.Tests.Examples
22
{
33
public class TernaryOperator
44
{
55
public int Test1()
66
{
77
var temp = 1;
88

9-
if(temp == 2)
9+
if (temp == 2)
1010
return 3;
1111
else
1212
return 4;
@@ -16,7 +16,7 @@ public int Test2()
1616
{
1717
var temp = 5;
1818

19-
if(temp == 6)
19+
if (temp == 6)
2020
return 7;
2121
else
2222
return 8;
@@ -26,25 +26,13 @@ public int Test3()
2626
{
2727
var temp2 = 1;
2828

29-
if(temp2 == 2)
29+
if (temp2 == 2)
3030
return 3;
3131
else
3232
return 4;
3333
}
3434

35-
public int Test4()
36-
{
37-
var temp3 = 5;
38-
39-
if(temp3 == 6)
40-
return 7;
41-
else if (temp3 == 8)
42-
return 9;
43-
else
44-
return 10;
45-
}
46-
47-
public void Test5()
35+
public static void Test5()
4836
{
4937

5038
}

src/SimpleStateMachine.StructuralSearch.Tests/ExamplesOutput/NullUnionOperator.cs

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

0 commit comments

Comments
 (0)