mirror of
https://github.com/Smaug123/unofficial-nunit-runner
synced 2025-10-10 03:28:40 +00:00
Move to WoofWare.PrattParser
This commit is contained in:
115
TestRunner/TestRunner.Test/TestFilter.fs
Normal file
115
TestRunner/TestRunner.Test/TestFilter.fs
Normal file
@@ -0,0 +1,115 @@
|
||||
namespace TestRunner.Test
|
||||
|
||||
open TestRunner
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
|
||||
[<TestFixture>]
|
||||
module TestFilter =
|
||||
|
||||
let docExamples =
|
||||
[
|
||||
"(Name~MyClass) | (Name~MyClass2)",
|
||||
FilterIntermediate.Or (
|
||||
FilterIntermediate.Contains (FilterIntermediate.Name, FilterIntermediate.String "MyClass"),
|
||||
FilterIntermediate.Contains (FilterIntermediate.Name, FilterIntermediate.String "MyClass2")
|
||||
)
|
||||
"xyz", FilterIntermediate.Contains (FilterIntermediate.FullyQualifiedName, FilterIntermediate.String "xyz")
|
||||
"FullyQualifiedName~xyz",
|
||||
FilterIntermediate.Contains (FilterIntermediate.FullyQualifiedName, FilterIntermediate.String "xyz")
|
||||
"FullyQualifiedName!~IntegrationTests",
|
||||
FilterIntermediate.Not (
|
||||
FilterIntermediate.Contains (
|
||||
FilterIntermediate.FullyQualifiedName,
|
||||
FilterIntermediate.String "IntegrationTests"
|
||||
)
|
||||
)
|
||||
"FullyQualifiedName=MyNamespace.MyTestsClass<ParameterType1%2CParameterType2>.MyTestMethod",
|
||||
FilterIntermediate.Equal (
|
||||
FilterIntermediate.FullyQualifiedName,
|
||||
FilterIntermediate.String "MyNamespace.MyTestsClass<ParameterType1%2CParameterType2>.MyTestMethod"
|
||||
)
|
||||
"Name~Method", FilterIntermediate.Contains (FilterIntermediate.Name, FilterIntermediate.String "Method")
|
||||
"FullyQualifiedName!=MSTestNamespace.UnitTest1.TestMethod1",
|
||||
FilterIntermediate.Not (
|
||||
FilterIntermediate.Equal (
|
||||
FilterIntermediate.FullyQualifiedName,
|
||||
FilterIntermediate.String "MSTestNamespace.UnitTest1.TestMethod1"
|
||||
)
|
||||
)
|
||||
"TestCategory=CategoryA",
|
||||
FilterIntermediate.Equal (FilterIntermediate.TestCategory, FilterIntermediate.String "CategoryA")
|
||||
"FullyQualifiedName~UnitTest1|TestCategory=CategoryA",
|
||||
FilterIntermediate.Or (
|
||||
FilterIntermediate.Contains (
|
||||
FilterIntermediate.FullyQualifiedName,
|
||||
FilterIntermediate.String "UnitTest1"
|
||||
),
|
||||
FilterIntermediate.Equal (FilterIntermediate.TestCategory, FilterIntermediate.String "CategoryA")
|
||||
)
|
||||
"FullyQualifiedName~UnitTest1&TestCategory=CategoryA",
|
||||
FilterIntermediate.And (
|
||||
FilterIntermediate.Contains (
|
||||
FilterIntermediate.FullyQualifiedName,
|
||||
FilterIntermediate.String "UnitTest1"
|
||||
),
|
||||
FilterIntermediate.Equal (FilterIntermediate.TestCategory, FilterIntermediate.String "CategoryA")
|
||||
)
|
||||
"(FullyQualifiedName~UnitTest1&TestCategory=CategoryA)|TestCategory=1",
|
||||
FilterIntermediate.Or (
|
||||
FilterIntermediate.And (
|
||||
FilterIntermediate.Contains (
|
||||
FilterIntermediate.FullyQualifiedName,
|
||||
FilterIntermediate.String "UnitTest1"
|
||||
),
|
||||
FilterIntermediate.Equal (FilterIntermediate.TestCategory, FilterIntermediate.String "CategoryA")
|
||||
),
|
||||
FilterIntermediate.Equal (FilterIntermediate.TestCategory, FilterIntermediate.String "1")
|
||||
)
|
||||
]
|
||||
|> List.map TestCaseData
|
||||
|
||||
[<TestCaseSource(nameof docExamples)>]
|
||||
let ``Doc examples`` (example : string, expected : FilterIntermediate) =
|
||||
FilterIntermediate.parse example |> shouldEqual expected
|
||||
|
||||
let docExamplesRefined =
|
||||
[
|
||||
"(Name~MyClass) | (Name~MyClass2)",
|
||||
Filter.Or (Filter.Name (Match.Contains "MyClass"), Filter.Name (Match.Contains "MyClass2"))
|
||||
"xyz", Filter.FullyQualifiedName (Match.Contains "xyz")
|
||||
"FullyQualifiedName~xyz", Filter.FullyQualifiedName (Match.Contains "xyz")
|
||||
"FullyQualifiedName!~IntegrationTests",
|
||||
Filter.Not (Filter.FullyQualifiedName (Match.Contains "IntegrationTests"))
|
||||
"FullyQualifiedName=MyNamespace.MyTestsClass<ParameterType1%2CParameterType2>.MyTestMethod",
|
||||
Filter.FullyQualifiedName (
|
||||
Match.Exact "MyNamespace.MyTestsClass<ParameterType1%2CParameterType2>.MyTestMethod"
|
||||
)
|
||||
"Name~Method", Filter.Name (Match.Contains "Method")
|
||||
"FullyQualifiedName!=MSTestNamespace.UnitTest1.TestMethod1",
|
||||
Filter.Not (Filter.FullyQualifiedName (Match.Exact "MSTestNamespace.UnitTest1.TestMethod1"))
|
||||
"TestCategory=CategoryA", Filter.TestCategory (Match.Exact "CategoryA")
|
||||
"FullyQualifiedName~UnitTest1|TestCategory=CategoryA",
|
||||
Filter.Or (
|
||||
Filter.FullyQualifiedName (Match.Contains "UnitTest1"),
|
||||
Filter.TestCategory (Match.Exact "CategoryA")
|
||||
)
|
||||
"FullyQualifiedName~UnitTest1&TestCategory=CategoryA",
|
||||
Filter.And (
|
||||
Filter.FullyQualifiedName (Match.Contains "UnitTest1"),
|
||||
Filter.TestCategory (Match.Exact "CategoryA")
|
||||
)
|
||||
"(FullyQualifiedName~UnitTest1&TestCategory=CategoryA)|TestCategory=1",
|
||||
Filter.Or (
|
||||
Filter.And (
|
||||
Filter.FullyQualifiedName (Match.Contains "UnitTest1"),
|
||||
Filter.TestCategory (Match.Exact "CategoryA")
|
||||
),
|
||||
Filter.TestCategory (Match.Exact "1")
|
||||
)
|
||||
]
|
||||
|> List.map TestCaseData
|
||||
|
||||
[<TestCaseSource(nameof docExamplesRefined)>]
|
||||
let ``Doc examples, refined`` (example : string, expected : Filter) =
|
||||
FilterIntermediate.parse example |> Filter.make |> shouldEqual expected
|
27
TestRunner/TestRunner.Test/TestRunner.Test.fsproj
Normal file
27
TestRunner/TestRunner.Test/TestRunner.Test.fsproj
Normal file
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="TestFilter.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
|
||||
<PackageReference Include="FsUnit" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
|
||||
<PackageReference Include="NUnit" Version="4.1.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.9.0"/>
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TestRunner.fsproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Reference in New Issue
Block a user