GPreviatti.Util.JsonResourceAttribute 8.0.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package GPreviatti.Util.JsonResourceAttribute --version 8.0.9                
NuGet\Install-Package GPreviatti.Util.JsonResourceAttribute -Version 8.0.9                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GPreviatti.Util.JsonResourceAttribute" Version="8.0.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GPreviatti.Util.JsonResourceAttribute --version 8.0.9                
#r "nuget: GPreviatti.Util.JsonResourceAttribute, 8.0.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install GPreviatti.Util.JsonResourceAttribute as a Cake Addin
#addin nuget:?package=GPreviatti.Util.JsonResourceAttribute&version=8.0.9

// Install GPreviatti.Util.JsonResourceAttribute as a Cake Tool
#tool nuget:?package=GPreviatti.Util.JsonResourceAttribute&version=8.0.9                

Json Resource Attribute Package

This simple package that exposes an attribute to helps testing with json files.

How to use

Install package in test project and add this block in your csproj file in order to copy your json files into the debug folder

<ItemGroup>
	<None Remove="**\*.json" />
	<EmbeddedResource Include="**\*.json" Exclude="bin\**;obj\**" />
</ItemGroup>

You should create a json file and add the node with a name that will be identified by the test in the example the name is majorAge

Decorate your test method with JsonResourceData attribute, add the json file reference and test node name

[Theory(DisplayName = nameof(People_Should_Have_Major_Age))]
[JsonResourceData("json-resource-data-attribute.json", "majorAge")]
public void People_Should_Have_Major_Age(Person[] people, bool expected)
{
    // Arrange, Act
    var result = people.Any(p => p.IsMajorAge().Equals(expected));

    // Assert
    Assert.True(result);
}

Samples

The samples of how to use the json resource attribute are available in test project of package

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.19 306 1/16/2024
8.0.18 106 1/16/2024
8.0.17 106 1/16/2024
8.0.16 106 1/16/2024
8.0.15 101 1/16/2024
8.0.14 110 1/16/2024
8.0.13 112 1/16/2024
8.0.12 110 1/16/2024
8.0.11 105 1/16/2024
8.0.10 116 1/16/2024
8.0.9 108 1/16/2024
8.0.8 113 1/16/2024
8.0.7 97 1/16/2024
8.0.6 110 1/15/2024
8.0.4 114 1/15/2024
1.0.0 121 1/15/2024

Improve package namespace and folder