Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pidgin" Version="3.1.0" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="Pidgin" Version="3.2.0" />
<PackageReference Include="YamlDotNet" Version="12.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Configurations:
# AssignmentNullUnionOperator
- FindTemplate: |-
if($var$ $sign$ null)
if ($var$ $sign$ null)
{
$var$ = $value$;
}
Expand All @@ -14,7 +14,7 @@
# NullUnionOperator

- FindTemplate: |-
if($value$ $sign$ null)
if ($value$ $sign$ null)
$var$ = $value2$;
else
$var$ = $value1$;
Expand All @@ -29,7 +29,7 @@
# TernaryOperator

- FindTemplate: |-
if($condition$)
if ($condition$)
return $value1$;
else
return $value2$;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Configurations:
- FindTemplate: if($var1$ == $var2$)
- FindTemplate: if ($var1$ == $var2$)
FindRules:
- $var1$ Is Var
- $var2$ is Var
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Configurations:
# AssignmentNullUnionOperator
- FindTemplate: |-
if($var$ $sign$ null)
if ($var$ $sign$ null)
{
$var$ = $value$;
}
Expand All @@ -13,7 +13,7 @@
# NullUnionOperator

- FindTemplate: |-
if($value$ $sign$ null)
if ($value$ $sign$ null)
$var$ = $value2$;
else
$var$ = $value1$;
Expand All @@ -28,7 +28,7 @@
# TernaryOperator

- FindTemplate: |-
if($condition$)
if ($condition$)
return $value1$;
else
return $value2$;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,35 @@
using SimpleStateMachine.StructuralSearch.Tests.Mock;
using Xunit;

namespace SimpleStateMachine.StructuralSearch.Tests
namespace SimpleStateMachine.StructuralSearch.Tests;

public static class ConfigurationFileParserTests
{
public class ConfigurationFileParserTests
[Theory]
[InlineData("ConfigurationFile/ShortConfig.yml")]
[InlineData("ConfigurationFile/FullConfig.yml")]
public static void ConfigurationFileParsingShouldBeSuccess(string filePath)
{
[Theory]
[InlineData("ConfigurationFile/ShortConfig.yml")]
[InlineData("ConfigurationFile/FullConfig.yml")]
public void ConfigurationFileParsingShouldBeSuccess(string filePath)
{
var cfg = YmlHelper.Parse(filePath);
var mock = Mock();
Assert.Equal(mock, cfg);
}
var cfg = YmlHelper.Parse(filePath);
var mock = Mock();
Assert.Equal(mock, cfg);
}

private ConfigurationFile Mock()
{
var names = new[] { "AssignmentNullUnionOperator", "NullUnionOperator", "TernaryOperator"};

var configurationFile = new ConfigurationFile
{
Configurations = new List<Configuration>()
};

foreach (var name in names)
{
var config = ConfigurationMock.GetConfigurationFromFiles(name);
configurationFile.Configurations.Add(config);
}
private static ConfigurationFile Mock()
{
var names = new[] { "AssignmentNullUnionOperator", "NullUnionOperator", "TernaryOperator"};

var configurationFile = new ConfigurationFile
(
configurations: new List<Configuration>()
);

return configurationFile;
foreach (var name in names)
{
var config = ConfigurationMock.GetConfigurationFromFiles(name);
configurationFile.Configurations.Add(config);
}

return configurationFile;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ public int Method1()
{
var temp = 5;

if(temp == 6)
if (temp == 6)
return 7;
else
return 8;
}

public void Method2()
public static void Method2()
{
int? result;
int? temp1 = 5;
int? temp2 = 5;
if(temp1 is null)
if (temp1 is null)
result = temp2;
else
result = temp1;
}

public void Method3()
public static void Method3()
{
int result;
int? temp1 = 5;
int? temp2 = 5;
if(temp1 is null)
if (temp1 is null)
result = temp2.Value;
else
result = temp1.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ public int Method1()
return temp == 6 ? 7 : 8;
}

public void Method2()
public static void Method2()
{
int? result;
int? temp1 = 5;
int? temp2 = 5;
result = temp1 ?? temp2;
}

public void Method3()
public static void Method3()
{
int result;
int? temp1 = 5;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
namespace SimpleStateMachine.StructuralSearch.Tests.ExamplesInput;
namespace SimpleStateMachine.StructuralSearch.Tests.Examples;

public class NullUnionOperator
{
public void Test1()
public static void Test1()
{
int? result;
int? temp1 = 5;
int? temp2 = 5;

if(temp1 is null)
if (temp1 is null)
result = temp2;
else
result = temp1;
}

public void Test2()
public static void Test2()
{

int? result;
int? temp1 = 6;
int? temp2 = 7;
if(temp1 is not null)
if (temp1 is not null)
result = temp2;
else
result = temp1;
}

public int Test3()
{
int? temp3 = 5;

if(temp3 is null)
return 7;
else if (temp3 == 8)
return 9;
else
return 10;
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace SimpleStateMachine.StructuralSearch.Tests.ExamplesInput
namespace SimpleStateMachine.StructuralSearch.Tests.Examples
{
public class TernaryOperator
{
public int Test1()
{
var temp = 1;

if(temp == 2)
if (temp == 2)
return 3;
else
return 4;
Expand All @@ -16,7 +16,7 @@ public int Test2()
{
var temp = 5;

if(temp == 6)
if (temp == 6)
return 7;
else
return 8;
Expand All @@ -26,25 +26,13 @@ public int Test3()
{
var temp2 = 1;

if(temp2 == 2)
if (temp2 == 2)
return 3;
else
return 4;
}

public int Test4()
{
var temp3 = 5;

if(temp3 == 6)
return 7;
else if (temp3 == 8)
return 9;
else
return 10;
}

public void Test5()
public static void Test5()
{

}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace SimpleStateMachine.StructuralSearch.Tests.Examples;

public class NullUnionOperator
{
public static void Test1()
{
int? result;
int? temp1 = 5;
int? temp2 = 5;

result = temp1 ?? temp2;
}

public static void Test2()
{

int? result;
int? temp1 = 6;
int? temp2 = 7;
result = temp2 ?? temp1;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace SimpleStateMachine.StructuralSearch.Tests.ExamplesInput
namespace SimpleStateMachine.StructuralSearch.Tests.Examples
{
public class TernaryOperator
{
Expand All @@ -25,19 +23,7 @@ namespace SimpleStateMachine.StructuralSearch.Tests.ExamplesInput
return temp2 == 2? 3 : 4;
}

public int Test4()
{
var temp3 = 5;

if(temp3 == 6)
return 7;
else if (temp3 == 8)
return 9;
else
return 10;
}

public void Test5()
public static void Test5()
{

}
Expand Down
Loading