-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactoring - adding some sense into tuples * Refactoring - adding unit tests project * Test for AutocompleteTokenizer * Added unit test for broken behavior * Fixing the case sensitivity in autocomplete * PR fixes
- Loading branch information
Víťa Tauer
authored
Apr 27, 2021
1 parent
0a83acc
commit 94be65b
Showing
7 changed files
with
156 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using SwqlStudio.Autocomplete; | ||
using Xunit; | ||
|
||
namespace SwqlStudio.Tests | ||
{ | ||
public class AutocompleteProviderTest | ||
{ | ||
[Theory] | ||
[MemberData(nameof(DoTheParsing_TestCases))] | ||
public void DoTheParsing_IdentifiesAliases(string query, Dictionary<string, string> expected) | ||
{ | ||
var provider = new AutocompleteProvider(query); | ||
var aliases = new Dictionary<string, string>(); | ||
provider.DoTheParsing(9, aliases); | ||
|
||
aliases.Should().BeEquivalentTo(expected); | ||
} | ||
|
||
public static IEnumerable<object[]> DoTheParsing_TestCases() | ||
{ | ||
yield return new object[] | ||
{ | ||
"select n. from Orion.Nodes n inner join Orion.Interfaces as i", | ||
new Dictionary<string, string> {["n"] = "Orion.Nodes", ["i"] = "Orion.Interfaces"} | ||
}; | ||
|
||
yield return new object[] | ||
{ | ||
"SELECT n. FROM Orion.Nodes n INNER JOIN Orion.Interfaces AS i", | ||
new Dictionary<string, string> {["n"] = "Orion.Nodes", ["i"] = "Orion.Interfaces"} | ||
}; | ||
|
||
yield return new object[] | ||
{ | ||
"select n. from Orion.Nodes n", | ||
new Dictionary<string, string> {["n"] = "Orion.Nodes"} | ||
}; | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using SwqlStudio.Autocomplete; | ||
using Xunit; | ||
|
||
namespace SwqlStudio.Tests | ||
{ | ||
public class AutocompleteTokenizerTest | ||
{ | ||
[Fact] | ||
public void TokenizerTestSuite() | ||
{ | ||
var tokenizer = new AutocompleteTokenizer( | ||
"SELECT n. Orion.Nodes 123 \"abc\""); | ||
|
||
IEnumerable<(int Position, int Length, AutocompleteTokenizer.Token Token)> Enumerate() | ||
{ | ||
foreach(var t in tokenizer) | ||
yield return t; | ||
} | ||
|
||
Enumerate().Should().BeEquivalentTo(new [] | ||
{ | ||
(0, 6, AutocompleteTokenizer.Token.Identifier), | ||
(7, 1, AutocompleteTokenizer.Token.Identifier), | ||
(8, 1, AutocompleteTokenizer.Token.Special), | ||
(10, 5, AutocompleteTokenizer.Token.Identifier), | ||
(15, 1, AutocompleteTokenizer.Token.Special), | ||
(16, 5, AutocompleteTokenizer.Token.Identifier), | ||
(22, 4, AutocompleteTokenizer.Token.Number), | ||
(26, 5, AutocompleteTokenizer.Token.String), | ||
(31, 0, AutocompleteTokenizer.Token.EOF), | ||
}); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="5.10.3" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="1.3.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Src\SwqlStudio\SwqlStudio.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |