-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added markdown readme files to nuget packages (#24)
- Loading branch information
Showing
24 changed files
with
362 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,34 @@ | ||
# EasyTestFile | ||
|
||
EasyTestFile is a library that simplifies the creation and usage of testfiles in unittests. | ||
Testfiles (like text, json, xml, binary, jpg, etc. etc.) are named based on the class and method name, are created if not exist, and are embedded as resource making sure the execution of the test is deterministic and do not rely on untracked files etc. | ||
|
||
# EasyTestFile.Json | ||
|
||
This package contains extension method(s) to deserialize TestFiles using json. | ||
|
||
<!-- snippet: LoadJson --> | ||
<a id='snippet-loadjson'></a> | ||
```cs | ||
[Fact] // or [Test] | ||
public async Task JsonTestFile() | ||
{ | ||
// load testfile | ||
var settings = new EasyTestFileSettings(); | ||
settings.UseExtension("json"); | ||
TestFile testFile = EasyTestFile.Load(settings); | ||
|
||
// deserialize testfile using Newtonsoft Json. | ||
Person person = await testFile.AsObjectUsingNewtonsoft<Person>(); | ||
|
||
// do something with person object | ||
// i.e. sut.Process(person); | ||
} | ||
|
||
public class Person | ||
{ | ||
public string Name { get; set; } | ||
} | ||
``` | ||
<sup><a href='/tests/EasyTestFile.Xunit.Tests/Samples/UnitTestClass.cs#L36-L56' title='Snippet source file'>snippet source</a> | <a href='#snippet-loadjson' title='Start of snippet'>anchor</a></sup> | ||
<!-- endSnippet --> |
This file contains 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
This file contains 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,63 @@ | ||
# EasyTestFile | ||
|
||
EasyTestFile is a library that simplifies the creation and usage of testfiles in unittests. | ||
Testfiles (like text, json, xml, binary, jpg, etc. etc.) are named based on the class and method name, are created if not exist, and are embedded as resource making sure the execution of the test is deterministic and do not rely on untracked files etc. | ||
|
||
# EasyTestFile.Nunit | ||
|
||
This package is required when your project uses NUnit for unittesting. No setup is required. | ||
|
||
## Samples | ||
|
||
<!-- snippet: NunitLoadAsText --> | ||
<a id='snippet-nunitloadastext'></a> | ||
```cs | ||
[Test] | ||
public async Task LoadAsText() | ||
{ | ||
// Executing this test for the first time will create an empty testfile and throw an exception. | ||
// Executing this test for the second time, this statement will read the testfile | ||
// and returns the content as a string. | ||
string text = await EasyTestFile.LoadAsText(); | ||
|
||
// and do whatever you want | ||
} | ||
``` | ||
<sup><a href='/tests/EasyTestFile.Nunit.Tests/Samples/UnitTestClass.cs#L11-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-nunitloadastext' title='Start of snippet'>anchor</a></sup> | ||
<!-- endSnippet --> | ||
|
||
<!-- snippet: NunitLoadAsStream --> | ||
<a id='snippet-nunitloadasstream'></a> | ||
```cs | ||
[Test] | ||
public async Task LoadAsStream() | ||
{ | ||
// You can also load the testfile content as a stream. | ||
Stream stream = await EasyTestFile.LoadAsStream(); | ||
|
||
} | ||
``` | ||
<sup><a href='/tests/EasyTestFile.Nunit.Tests/Samples/UnitTestClass.cs#L24-L32' title='Snippet source file'>snippet source</a> | <a href='#snippet-nunitloadasstream' title='Start of snippet'>anchor</a></sup> | ||
<!-- endSnippet --> | ||
|
||
Or load the TestFile object first | ||
|
||
<!-- snippet: NunitLoadAsTestFileBasic --> | ||
<a id='snippet-nunitloadastestfilebasic'></a> | ||
```cs | ||
[Test] | ||
public async Task LoadAsTestFile() | ||
{ | ||
// You can also load the test file as a TestFile object. | ||
TestFile testFile = EasyTestFile.Load(); | ||
|
||
// then you can load the content as a stream | ||
Stream stream = testFile.AsStream(); | ||
|
||
// or like | ||
string text = await testFile.AsText(); | ||
} | ||
``` | ||
<sup><a href='/tests/EasyTestFile.Nunit.Tests/Samples/UnitTestClass.cs#L58-L71' title='Snippet source file'>snippet source</a> | <a href='#snippet-nunitloadastestfilebasic' title='Start of snippet'>anchor</a></sup> | ||
<!-- endSnippet --> | ||
|
This file contains 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
This file contains 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,77 @@ | ||
# EasyTestFile | ||
|
||
EasyTestFile is a library that simplifies the creation and usage of testfiles in unittests. | ||
Testfiles (like text, json, xml, binary, jpg, etc. etc.) are named based on the class and method name, are created if not exist, and are embedded as resource making sure the execution of the test is deterministic and do not rely on untracked files etc. | ||
|
||
# EasyTestFile.Nunit | ||
|
||
This package is required when your project uses NUnit for unittesting. Make sure your test class is annotated with the attribute `[EasyTestFileXunit.UsesEasyTestFile]`. | ||
|
||
## Attribute usage | ||
<!-- snippet: XUnitAttributeUsage --> | ||
<a id='snippet-xunitattributeusage'></a> | ||
```cs | ||
[UsesEasyTestFile] | ||
public class TestClass1 | ||
{ | ||
// The attribute is required when using XUnit. | ||
} | ||
``` | ||
<sup><a href='/tests/EasyTestFile.Xunit.Tests/Samples/Samples.cs#L6-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitattributeusage' title='Start of snippet'>anchor</a></sup> | ||
<!-- endSnippet --> | ||
|
||
## Usage | ||
|
||
Default options to load as text or load as stream: | ||
|
||
<!-- snippet: LoadAsText --> | ||
<a id='snippet-loadastext'></a> | ||
```cs | ||
[Fact] | ||
public async Task LoadAsText() | ||
{ | ||
// Executing this test for the first time will create an empty testfile and throw an exception. | ||
// Executing this test for the second time, this statement will read the testfile | ||
// and returns the content as a string. | ||
string text = await EasyTestFile.LoadAsText(); | ||
|
||
// and do whatever you want | ||
} | ||
``` | ||
<sup><a href='/tests/EasyTestFile.Xunit.Tests/Samples/UnitTestClass.cs#L12-L23' title='Snippet source file'>snippet source</a> | <a href='#snippet-loadastext' title='Start of snippet'>anchor</a></sup> | ||
<!-- endSnippet --> | ||
|
||
<!-- snippet: LoadAsStream --> | ||
<a id='snippet-loadasstream'></a> | ||
```cs | ||
[Fact] | ||
public async Task LoadAsStream() | ||
{ | ||
// You can also load the testfile content as a stream. | ||
Stream stream = await EasyTestFile.LoadAsStream(); | ||
|
||
} | ||
``` | ||
<sup><a href='/tests/EasyTestFile.Xunit.Tests/Samples/UnitTestClass.cs#L25-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-loadasstream' title='Start of snippet'>anchor</a></sup> | ||
<!-- endSnippet --> | ||
|
||
Or load the TestFile object first | ||
|
||
<!-- snippet: LoadAsTestFileBasic --> | ||
<a id='snippet-loadastestfilebasic'></a> | ||
```cs | ||
[Fact] | ||
public async Task LoadAsTestFile() | ||
{ | ||
// You can also load the test file as a TestFile object. | ||
TestFile testFile = EasyTestFile.Load(); | ||
|
||
// then you can load the content as a stream | ||
Stream stream = testFile.AsStream(); | ||
|
||
// or like | ||
string text = await testFile.AsText(); | ||
} | ||
``` | ||
<sup><a href='/tests/EasyTestFile.Xunit.Tests/Samples/UnitTestClass.cs#L59-L72' title='Snippet source file'>snippet source</a> | <a href='#snippet-loadastestfilebasic' title='Start of snippet'>anchor</a></sup> | ||
<!-- endSnippet --> |
This file contains 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
This file contains 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,6 @@ | ||
# EasyTestFile | ||
|
||
EasyTestFile is a library that simplifies the creation and usage of testfiles in unittests. | ||
Testfiles (like text, json, xml, binary, jpg, etc. etc.) are named based on the class and method name, are created if not exist, and are embedded as resource making sure the execution of the test is deterministic and do not rely on untracked files etc. | ||
|
||
This package contains EasyTestFile framework independent logic. You should also refrence [EasyTestFile.XUnit](https://www.nuget.org/packages/EasyTestFile.XUnit/) or [EasyTestFile.NUnit](https://www.nuget.org/packages/EasyTestFile.NUnit/) depending on your test framwork. |
This file contains 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,10 @@ | ||
[*.cs] | ||
# | ||
# Rules disabled due to sample code. | ||
# | ||
|
||
# IDE0007: Use implicit type | ||
dotnet_diagnostic.IDE0007.severity = none | ||
|
||
# IDE0059: Unnecessary assignment of a value | ||
dotnet_diagnostic.IDE0059.severity = none |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Oops, something went wrong.