Ensure.That is a simple guard clause argument validation lib, that helps you with validation of your arguments.
NuGet(dll)
NuGet(src)
Could be used with different profiles. Like Debug
and CI
is On
while Release
is Off
.
#if RELEASE
Ensure.Off()
#endif
Ensure.That(myString, nameof(myArg)).IsNotNullOrWhiteSpace();
Ensure.That(myString, "myArg").IsNotNullOrWhiteSpace();
NOTE! I personally would not use the lambda version below to get the name of the argument. I would rather use the nameof
construct or manually defining the name of the argument.
From v3.1.0
support for lambdas to extract the param-name and/or value has been added, hence you can now do:
//Note! Makes a compile of the lambda to get the value. Also extracts the param name "person.Name" from the expression.
Ensure.That(() => person.Name).IsNotNullOrWhiteSpace();
//Note! Makes a compile of the lambda to get the value. Does NOT extract the param name "person.Name" from the expression.
Ensure.That(() => person.Name, "The name param").IsNotNullOrWhiteSpace();
//Note! Does NOT make a compile of the lambda. Only parses the expression to get the param name "person.Name" from the expression.
Ensure.That(person.Name, () => person.Name).IsNotNullOrWhiteSpace();
Available from v2.0.0
, https://github.com/danielwertheim/Ensure.That/wiki/Release-notes
Ensure.That is distributed via NuGet. Either as a portable library (for .Net4+, Silverlight, Windows Phone, WinRT
) or as an includable source package.
Since v3.0.0
there's included support for vNext.
The documentation is contained in the project wiki.
The main solution is maintained using Visual Studio 2015.
Please note. No NuGet packages are checked in. If you are using the latest version of NuGet (v2.7.1+) you should be able to just build and the packages will be restored. If this does not work, you could install the missing NuGet packages using a simple PowerShell script as covered here
Unit-tests are written using xUnit
and there are no integration tests, hence you should just be able to: Pull
-Compile
&Run the tests
.
There's a gulp.js
file under .\deploy
. It requires that you have nuget.exe
in your path. Other than that, you should be able to run the tasks to restore tools, build, run tests and pack NuPkgs.
This is described in the wiki, under: "How-to Contribute".
Pull request should be against the develop
branch
So you have issues or questions... Great! That means someone is using it. Use the issues function here at the project page or contact me via mail: firstname@lastname.se; or Twitter: @danielwertheim