Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gpreviatti/json-resource-attribute-package
This simple package that exposes an attribute to helps testing with json files
https://github.com/gpreviatti/json-resource-attribute-package
chsarp dotnet nuget nuget-package tdd test testing xunit
Last synced: 9 days ago
JSON representation
This simple package that exposes an attribute to helps testing with json files
- Host: GitHub
- URL: https://github.com/gpreviatti/json-resource-attribute-package
- Owner: gpreviatti
- Created: 2024-01-15T18:03:57.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-23T19:41:04.000Z (about 1 year ago)
- Last Synced: 2024-04-26T06:21:31.465Z (9 months ago)
- Topics: chsarp, dotnet, nuget, nuget-package, tdd, test, testing, xunit
- Language: C#
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Json Resource Attribute Package
[![Publish in Nuget.org](https://github.com/gpreviatti/json-resource-attribute-package/actions/workflows/publish.yml/badge.svg)](https://github.com/gpreviatti/json-resource-attribute-package/actions/workflows/publish.yml)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=gpreviatti_json-resource-attribute-package&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=gpreviatti_json-resource-attribute-package)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=gpreviatti_json-resource-attribute-package&metric=bugs)](https://sonarcloud.io/summary/new_code?id=gpreviatti_json-resource-attribute-package)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=gpreviatti_json-resource-attribute-package&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=gpreviatti_json-resource-attribute-package)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=gpreviatti_json-resource-attribute-package&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=gpreviatti_json-resource-attribute-package)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=gpreviatti_json-resource-attribute-package&metric=coverage)](https://sonarcloud.io/summary/new_code?id=gpreviatti_json-resource-attribute-package)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=gpreviatti_json-resource-attribute-package&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=gpreviatti_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
```xml
```
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
```csharp
[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](https://github.com/gpreviatti/json-resource-attribute-package/blob/main/tests/GPreviatti.Util.JsonResourceAttribute.Tests/JsonResourceDataTests.cs)