-
Notifications
You must be signed in to change notification settings - Fork 57
Created basic xUnit tests #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3db13d2
Initial xUnit test
a583941
Additional pattern tests
35e7994
Initial xUnit test
be3d610
Refactor and vscode added to gitignore
617efa2
-
60d87c2
Delete launch.json
Justin-Lloyd ea776e8
Delete tasks.json
Justin-Lloyd 735e343
Email pattern test
Justin-Lloyd 260cc1a
updated email address
Justin-Lloyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| { | ||
| // Use IntelliSense to find out which attributes exist for C# debugging | ||
| // Use hover for the description of the existing attributes | ||
| // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": ".NET Core Launch (console)", | ||
| "type": "coreclr", | ||
| "request": "launch", | ||
| "preLaunchTask": "build", | ||
| // If you have changed target frameworks, make sure to update the program path. | ||
| "program": "${workspaceFolder}/src/Grok.Net.Tests/bin/Debug/netcoreapp2.1/Grok.Net.Tests.dll", | ||
| "args": [], | ||
| "cwd": "${workspaceFolder}/src/Grok.Net.Tests", | ||
| // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console | ||
| "console": "internalConsole", | ||
| "stopAtEntry": false | ||
| }, | ||
| { | ||
| "name": ".NET Core Attach", | ||
| "type": "coreclr", | ||
| "request": "attach", | ||
| "processId": "${command:pickProcess}" | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or 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,42 @@ | ||
| { | ||
Marusyk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "version": "2.0.0", | ||
| "tasks": [ | ||
| { | ||
| "label": "build", | ||
| "command": "dotnet", | ||
| "type": "process", | ||
| "args": [ | ||
| "build", | ||
| "${workspaceFolder}/src/Grok.Net.Tests/Grok.Net.Tests.csproj", | ||
| "/property:GenerateFullPaths=true", | ||
| "/consoleloggerparameters:NoSummary" | ||
| ], | ||
| "problemMatcher": "$msCompile" | ||
| }, | ||
| { | ||
| "label": "publish", | ||
| "command": "dotnet", | ||
| "type": "process", | ||
| "args": [ | ||
| "publish", | ||
| "${workspaceFolder}/src/Grok.Net.Tests/Grok.Net.Tests.csproj", | ||
| "/property:GenerateFullPaths=true", | ||
| "/consoleloggerparameters:NoSummary" | ||
| ], | ||
| "problemMatcher": "$msCompile" | ||
| }, | ||
| { | ||
| "label": "watch", | ||
| "command": "dotnet", | ||
| "type": "process", | ||
| "args": [ | ||
| "watch", | ||
| "run", | ||
| "${workspaceFolder}/src/Grok.Net.Tests/Grok.Net.Tests.csproj", | ||
| "/property:GenerateFullPaths=true", | ||
| "/consoleloggerparameters:NoSummary" | ||
| ], | ||
| "problemMatcher": "$msCompile" | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or 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,19 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
|
|
||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||
| <PackageReference Include="xunit" Version="2.4.0" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Grok.Net\Grok.Net.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or 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,67 @@ | ||
| using System; | ||
| using Xunit; | ||
| using GrokNet; | ||
|
|
||
| namespace GrokNetTests | ||
| { | ||
| public class UnitTests | ||
| { | ||
| [Fact] | ||
| public void ParseEmptyTest() | ||
| { | ||
| Grok act = new Grok(""); | ||
| GrokResult result = act.Parse(""); | ||
|
|
||
| Assert.NotNull(result); | ||
| Assert.Empty(result); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void PatternCountTest() | ||
Marusyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| Grok act = new Grok("%{MONTHDAY:month}-%{MONTHDAY:day}-%{MONTHDAY:year} %{TIME:timestamp};%{WORD:id};%{LOGLEVEL:loglevel};%{WORD:func};%{GREEDYDATA:msg}"); | ||
Marusyk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| string logs = @"06-21-19 21:00:13:589241;15;INFO;main;DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165 | ||
| 06-21-19 21:00:13:589265;156;WARN;main;DECODED: 775233900043 EMPTY DISTANCE: --------"; | ||
| GrokResult grokResult = act.Parse(logs); | ||
|
|
||
| Assert.Equal(16, grokResult.Count); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void MonthDayPatternTest() | ||
| { | ||
| Grok act = new Grok("%{MONTHDAY:month}-%{MONTHDAY:day}-%{MONTHDAY:year} %{TIME:timestamp};%{WORD:id};%{LOGLEVEL:loglevel};%{WORD:func};%{GREEDYDATA:msg}"); | ||
| string logs = @"06-21-19 21:00:13:589241;15;INFO;main;DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165 | ||
| 06-21-19 21:00:13:589265;156;WARN;main;DECODED: 775233900043 EMPTY DISTANCE: --------"; | ||
| GrokResult grokResult = act.Parse(logs); | ||
|
|
||
| Assert.Equal("month", grokResult[0].Key); | ||
| Assert.Equal("06", grokResult[0].Value); | ||
| Assert.Equal("day", grokResult[1].Key); | ||
| Assert.Equal("21", grokResult[1].Value); | ||
| Assert.Equal("year", grokResult[2].Key); | ||
| Assert.Equal("19", grokResult[2].Value); | ||
|
|
||
| Assert.Equal("month", grokResult[8].Key); | ||
| Assert.Equal("06", grokResult[8].Value); | ||
| Assert.Equal("day", grokResult[9].Key); | ||
| Assert.Equal("21", grokResult[9].Value); | ||
| Assert.Equal("year", grokResult[10].Key); | ||
| Assert.Equal("19", grokResult[10].Value); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void TimePatternTest() | ||
| { | ||
| Grok act = new Grok("%{MONTHDAY:month}-%{MONTHDAY:day}-%{MONTHDAY:year} %{TIME:timestamp};%{WORD:id};%{LOGLEVEL:loglevel};%{WORD:func};%{GREEDYDATA:msg}"); | ||
| string logs = @"06-21-19 21:00:13:589241;15;INFO;main;DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165 | ||
| 06-21-19 21:00:13:589265;156;WARN;main;DECODED: 775233900043 EMPTY DISTANCE: --------"; | ||
| GrokResult grokResult = act.Parse(logs); | ||
|
|
||
| Assert.Equal("21:00:13:589241", grokResult[3].Value); | ||
| Assert.Equal("21:00:13:589265", grokResult[11].Value); | ||
| } | ||
|
|
||
Marusyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| } | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.