Skip to content
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

Add "selector" configuration file #17

Merged
merged 2 commits into from
May 20, 2022
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,8 @@ coverage.cobertura.xml
*.diagsession

# Generated SpecFlow files
*.feature.cs
*.feature.cs

# NCrunch files
*.ncrunchsolution
*.ncrunchproject
5 changes: 4 additions & 1 deletion Solutions/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ dotnet_style_qualification_for_property = true:suggestion
dotnet_style_qualification_for_event = true:suggestion

# Style - using
csharp_using_directive_placement = inside_namespace:warning
csharp_using_directive_placement = inside_namespace:warning

# StyleCop currently chokes on various uses of record
dotnet_diagnostic.SA1201.severity = None
57 changes: 2 additions & 55 deletions Solutions/Corvus.Json.Specs/Corvus.Json.Specs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
<NoWarn>RCS1029;CS1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<SpecFlowObsoleteCodeBehindFiles Remove="Features\JsonModel\Arrays\JsonProperties.feature.cs" />
<SpecFlowObsoleteCodeBehindFiles Remove="Features\JsonModel\Equals\JsonAnyEquals - Copy.feature.cs" />
<SpecFlowObsoleteCodeBehindFiles Remove="Features\JsonModel\Equals\JsonArrayEquals - Copy.feature.cs" />
<SpecFlowObsoleteCodeBehindFiles Remove="Features\JsonModel\JsonSerialization - Copy.feature.cs" />
<SpecFlowObsoleteCodeBehindFiles Remove="Features\JsonModel\Properties\JsonSerialization.feature.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
Expand Down Expand Up @@ -55,59 +47,14 @@
<ProjectReference Include="..\Corvus.Json\Corvus.Json.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Features\JsonModel\Arrays\JsonArrays.feature.cs">
<DependentUpon>JsonArrays.feature</DependentUpon>
</Compile>
<Compile Update="Features\JsonModel\Equals\JsonNotAnyEquals.feature.cs">
<DependentUpon>JsonNotAnyEquals.feature</DependentUpon>
</Compile>
<Compile Update="Features\JsonModel\Equals\JsonAnyEquals.feature.cs">
<DependentUpon>JsonAnyEquals.feature</DependentUpon>
</Compile>
<Compile Update="Features\JsonModel\ValidationContext.feature.cs">
<DependentUpon>ValidationContext.feature</DependentUpon>
</Compile>
<Compile Update="Features\JsonModel\Properties\JsonProperties.feature.cs">
<DependentUpon>JsonProperties.feature</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<None Update="appsettings.local.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.local.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.template.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.local.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<SpecFlowFeatureFiles Update="Features\JsonModel\Arrays\JsonArrays.feature">
<Visible>$(UsingMicrosoftNETSdk)</Visible>
<CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile>
</SpecFlowFeatureFiles>
<SpecFlowFeatureFiles Update="Features\JsonModel\Equals\JsonNotAnyEquals.feature">
<Visible>$(UsingMicrosoftNETSdk)</Visible>
<CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile>
</SpecFlowFeatureFiles>
<SpecFlowFeatureFiles Update="Features\JsonModel\Equals\JsonAnyEquals.feature">
<Visible>$(UsingMicrosoftNETSdk)</Visible>
<CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile>
</SpecFlowFeatureFiles>
<SpecFlowFeatureFiles Update="Features\JsonModel\ValidationContext.feature">
<Visible>$(UsingMicrosoftNETSdk)</Visible>
<CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile>
</SpecFlowFeatureFiles>
<SpecFlowFeatureFiles Update="Features\JsonModel\Properties\JsonProperties.feature">
<Visible>$(UsingMicrosoftNETSdk)</Visible>
<CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile>
</SpecFlowFeatureFiles>
<PackageReference Update="StyleCop.Analyzers" Version="1.2.0-beta.435" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions Solutions/Corvus.Json.Specs/EnableParallelTestExecution.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// <copyright file="EnableParallelTestExecution.cs" company="Endjin Limited">
// Copyright (c) Endjin Limited. All rights reserved.
// </copyright>

using NUnit.Framework;

// Note: SpecFlow doesn't support parallelization of multiple scenarios within a single feature,
// so this is the highest level of parallelization available to us. See:
// https://docs.specflow.org/projects/specflow/en/latest/Execution/Parallel-Execution.html#nunit-configuration
[assembly: Parallelizable(ParallelScope.Fixtures)]
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,39 @@ Scenario Outline: $anchor inside an enum is not a real identifier
| #/003/tests/001/data | false | in implementations that strip $anchor, this may match either $def |
| #/003/tests/002/data | true | match $ref to $anchor |
| #/003/tests/003/data | false | no match on enum or $ref to $anchor |

Scenario Outline: same $anchor with different base uri
/* Schema:
{
"$id": "http://localhost:1234/foobar",
"$defs": {
"A": {
"$id": "child1",
"allOf": [
{
"$id": "child2",
"$anchor": "my_anchor",
"type": "number"
},
{
"$anchor": "my_anchor",
"type": "string"
}
]
}
},
"$ref": "child1#my_anchor"
}
*/
Given the input JSON file "anchor.json"
And the schema at "#/4/schema"
And the input data at "<inputDataReference>"
And I generate a type for the schema
And I construct an instance of the schema type from the data
When I validate the instance
Then the result will be <valid>

Examples:
| inputDataReference | valid | description |
| #/004/tests/000/data | true | $ref should resolve to /$defs/A/allOf/1 |
| #/004/tests/001/data | false | $ref should not resolve to /$defs/A/allOf/0 |
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,25 @@ Scenario Outline: items + contains
| #/004/tests/001/data | false | does not match items, matches contains |
| #/004/tests/002/data | true | matches both items and contains |
| #/004/tests/003/data | false | matches neither items nor contains |

Scenario Outline: contains with false if subschema
/* Schema:
{
"contains": {
"if": false,
"else": true
}
}
*/
Given the input JSON file "contains.json"
And the schema at "#/5/schema"
And the input data at "<inputDataReference>"
And I generate a type for the schema
And I construct an instance of the schema type from the data
When I validate the instance
Then the result will be <valid>

Examples:
| inputDataReference | valid | description |
| #/005/tests/000/data | true | any non-empty array is valid |
| #/005/tests/001/data | false | empty array is invalid |
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Feature: date-time draft2019-09

Scenario Outline: validation of date-time strings
/* Schema:
{"format": "date-time"}
{ "format": "date-time" }
*/
Given the input JSON file "date-time.json"
Given the input JSON file "optional\format\date-time.json"
And the schema at "#/0/schema"
And the input data at "<inputDataReference>"
And I generate a type for the schema
Expand All @@ -19,14 +19,28 @@ Scenario Outline: validation of date-time strings

Examples:
| inputDataReference | valid | description |
| #/000/tests/000/data | true | a valid date-time string |
| #/000/tests/001/data | true | a valid date-time string without second fraction |
| #/000/tests/002/data | true | a valid date-time string with plus offset |
| #/000/tests/003/data | true | a valid date-time string with minus offset |
| #/000/tests/004/data | false | a invalid day in date-time string |
| #/000/tests/005/data | false | an invalid offset in date-time string |
| #/000/tests/006/data | false | an invalid date-time string |
| #/000/tests/007/data | true | case-insensitive T and Z |
| #/000/tests/008/data | false | only RFC3339 not all of ISO 8601 are valid |
| #/000/tests/009/data | false | invalid non-padded month dates |
| #/000/tests/010/data | false | invalid non-padded day dates |
| #/000/tests/000/data | true | all string formats ignore integers |
| #/000/tests/001/data | true | all string formats ignore floats |
| #/000/tests/002/data | true | all string formats ignore objects |
| #/000/tests/003/data | true | all string formats ignore arrays |
| #/000/tests/004/data | true | all string formats ignore booleans |
| #/000/tests/005/data | true | all string formats ignore nulls |
| #/000/tests/006/data | true | a valid date-time string |
| #/000/tests/007/data | true | a valid date-time string without second fraction |
| #/000/tests/008/data | true | a valid date-time string with plus offset |
| #/000/tests/009/data | true | a valid date-time string with minus offset |
# #/000/tests/010/data | true | a valid date-time with a leap second, UTC |
# #/000/tests/011/data | true | a valid date-time with a leap second, with minus offset |
| #/000/tests/012/data | false | an invalid date-time past leap second, UTC |
| #/000/tests/013/data | false | an invalid date-time with leap second on a wrong minute, UTC |
| #/000/tests/014/data | false | an invalid date-time with leap second on a wrong hour, UTC |
| #/000/tests/015/data | false | an invalid day in date-time string |
| #/000/tests/016/data | false | an invalid offset in date-time string |
| #/000/tests/017/data | false | an invalid closing Z after time-zone offset |
| #/000/tests/018/data | false | an invalid date-time string |
| #/000/tests/019/data | true | case-insensitive T and Z |
| #/000/tests/020/data | false | only RFC3339 not all of ISO 8601 are valid |
| #/000/tests/021/data | false | invalid non-padded month dates |
| #/000/tests/022/data | false | invalid non-padded day dates |
| #/000/tests/023/data | false | non-ascii digits should be rejected in the date portion |
| #/000/tests/024/data | false | non-ascii digits should be rejected in the time portion |
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Feature: date draft2019-09

Scenario Outline: validation of date strings
/* Schema:
{"format": "date"}
{ "format": "date" }
*/
Given the input JSON file "date.json"
Given the input JSON file "optional\format\date.json"
And the schema at "#/0/schema"
And the input data at "<inputDataReference>"
And I generate a type for the schema
Expand All @@ -19,8 +19,46 @@ Scenario Outline: validation of date strings

Examples:
| inputDataReference | valid | description |
| #/000/tests/000/data | true | a valid date string |
| #/000/tests/001/data | false | an invalid date-time string |
| #/000/tests/002/data | false | only RFC3339 not all of ISO 8601 are valid |
| #/000/tests/003/data | false | invalidates non-padded month dates |
| #/000/tests/004/data | false | invalidates non-padded day dates |
| #/000/tests/000/data | true | all string formats ignore integers |
| #/000/tests/001/data | true | all string formats ignore floats |
| #/000/tests/002/data | true | all string formats ignore objects |
| #/000/tests/003/data | true | all string formats ignore arrays |
| #/000/tests/004/data | true | all string formats ignore booleans |
| #/000/tests/005/data | true | all string formats ignore nulls |
| #/000/tests/006/data | true | a valid date string |
| #/000/tests/007/data | true | a valid date string with 31 days in January |
| #/000/tests/008/data | false | a invalid date string with 32 days in January |
| #/000/tests/009/data | true | a valid date string with 28 days in February (normal) |
| #/000/tests/010/data | false | a invalid date string with 29 days in February (normal) |
| #/000/tests/011/data | true | a valid date string with 29 days in February (leap) |
| #/000/tests/012/data | false | a invalid date string with 30 days in February (leap) |
| #/000/tests/013/data | true | a valid date string with 31 days in March |
| #/000/tests/014/data | false | a invalid date string with 32 days in March |
| #/000/tests/015/data | true | a valid date string with 30 days in April |
| #/000/tests/016/data | false | a invalid date string with 31 days in April |
| #/000/tests/017/data | true | a valid date string with 31 days in May |
| #/000/tests/018/data | false | a invalid date string with 32 days in May |
| #/000/tests/019/data | true | a valid date string with 30 days in June |
| #/000/tests/020/data | false | a invalid date string with 31 days in June |
| #/000/tests/021/data | true | a valid date string with 31 days in July |
| #/000/tests/022/data | false | a invalid date string with 32 days in July |
| #/000/tests/023/data | true | a valid date string with 31 days in August |
| #/000/tests/024/data | false | a invalid date string with 32 days in August |
| #/000/tests/025/data | true | a valid date string with 30 days in September |
| #/000/tests/026/data | false | a invalid date string with 31 days in September |
| #/000/tests/027/data | true | a valid date string with 31 days in October |
| #/000/tests/028/data | false | a invalid date string with 32 days in October |
| #/000/tests/029/data | true | a valid date string with 30 days in November |
| #/000/tests/030/data | false | a invalid date string with 31 days in November |
| #/000/tests/031/data | true | a valid date string with 31 days in December |
| #/000/tests/032/data | false | a invalid date string with 32 days in December |
| #/000/tests/033/data | false | a invalid date string with invalid month |
| #/000/tests/034/data | false | an invalid date string |
| #/000/tests/035/data | false | only RFC3339 not all of ISO 8601 are valid |
| #/000/tests/036/data | false | non-padded month dates are not valid |
| #/000/tests/037/data | false | non-padded day dates are not valid |
| #/000/tests/038/data | false | invalid month |
| #/000/tests/039/data | false | invalid month-day combination |
| #/000/tests/040/data | false | 2021 is not a leap year |
| #/000/tests/041/data | true | 2020 is a leap year |
| #/000/tests/042/data | false | non-ascii digits should be rejected |
Loading