BlueDotBrigade.DatenLokator
2.1.0
Prefix Reserved
dotnet add package BlueDotBrigade.DatenLokator --version 2.1.0
NuGet\Install-Package BlueDotBrigade.DatenLokator -Version 2.1.0
<PackageReference Include="BlueDotBrigade.DatenLokator" Version="2.1.0" />
<PackageVersion Include="BlueDotBrigade.DatenLokator" Version="2.1.0" />
<PackageReference Include="BlueDotBrigade.DatenLokator" />
paket add BlueDotBrigade.DatenLokator --version 2.1.0
#r "nuget: BlueDotBrigade.DatenLokator, 2.1.0"
#:package BlueDotBrigade.DatenLokator@2.1.0
#addin nuget:?package=BlueDotBrigade.DatenLokator&version=2.1.0
#tool nuget:?package=BlueDotBrigade.DatenLokator&version=2.1.0
Daten Lokator
Overview
If your automated tests are verifying more than just value types (string
, int
, float
, etc), then consider using the BlueDotBrigade.DatenLokator NuGet package to automatically locate and load your test data (*.log
, *.xml
, *.json
, *.jpg
, etc). All you need to do is call one method:
new Daten().AsString()
Features
- Retrieve data in different formats:
AsBytes()
AsFile()
AsString()
AsStream()
AsStreamReader()
- Automatic decompression of
*.zip
files.- Useful for saving disk space.
- Global cache support.
- Useful when multiple tests consume the same file as input.
- Run-time customization.
- Can be used to specify where the input data will be stored.
- Extensible library.
- Create extension methods to support custom target formats (e.g.
AsRecord()
). - Implement the ITestNamingStrategy interface to support custom test naming conventions.
- Implement the IFileManagementStrategy interface for proprietary file management (e.g. cloud based storage).
- Create extension methods to support custom target formats (e.g.
Getting Started
Setup:
- Create a .NET automated test project.
- For example: Using Visual Studio add a MsTest Test Project to your solution.
- Daten Lokator will work with: MsTest, NUnit, XUnit, etc.
- Add the latest NuGet package to your test project:
- The Daten Lokator library must be initialized only once when the automated tests start.
- Example:
Lokator.Get().Setup()
- If you are using MsTest then consider doing this where the
AssemblyInitialize
attribute is used.
- Example:
- Create a
.Daten
folder within the project (*.csproj
) directory.- Example:
/DemoTests/.Daten
- Storing the input data within the project directory provides traceability, because now the input data can be committed to source control (e.g. GitHub).
- Example:
Managing source files:
- Create an automated test.
- By default it is assumed that test method name follows the Assert Act Arrange naming convention.
- Save the input data in a file directory structure that mirrors the namespace.
- For example:
- Unit Tests:
/DemoTests/Serialization/XmlSerializerTests.cs
- Input Data:
/DemoTests/.Daten/Serialization/XmlSerializerTests/*.*
- Unit Tests:
- Where:
.Daten
is Daten Lokator's root directory for all input files.Serialization
is the namespace where theXmlSerializerTests.cs
automated tests can be found.
- For example:
- When an input file is needed, simply call the appropriate
Daten
method from your automated test.- For example:
new Daten().AsString()
- For example:
Sample Code
The following unit tests, written for a trivial application, demonstrate how:
- easy it is to use Daten Lokator, and
- how the library reduces visual noise thus making the test easier to read
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- MSTest.TestFramework (>= 3.6.3)
- System.Collections.Immutable (>= 9.0.0)
- System.Configuration.ConfigurationManager (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
This libary is currently a work in progress (WIP). As a result, backwards compatibility is not guaranteed.