OpenAsserts 2.0.2

dotnet add package OpenAsserts --version 2.0.2
NuGet\Install-Package OpenAsserts -Version 2.0.2
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="OpenAsserts" Version="2.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenAsserts --version 2.0.2
#r "nuget: OpenAsserts, 2.0.2"
#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 OpenAsserts as a Cake Addin
#addin nuget:?package=OpenAsserts&version=2.0.2

// Install OpenAsserts as a Cake Tool
#tool nuget:?package=OpenAsserts&version=2.0.2

OpenAsserts

The Assert classes and methods we get out of the box cover a lot of what needs to be said about systems under test, but they're by no means comprehensive. OpenAsserts aims to fill some of the gaps. In these early implementations, the focus is on asserting against default values, but I intend to expand the project as I come up with more requirements or as I receive suggestions.

Examples

DefaultAssert Is/Not

As is typical with Assert vocabulary, I use "Is" and "IsNot" to assert that a single argument is or is not equal to the default for its type.

// Consider a Foo
public class Foo
{
  public string Name { get; private set; }
  public string Description { get; private set; }
  public DateTime LastModified {get; private set; }

  public void UpdateDescription(string description) {
    Description = description;
    LastModified = DateTime.Now;
  }
}

// Constructing one of these fills the properties with default values.
// Calling `UpdateDescription` mutates the timestamp.
// It can be tested like so:
[TestMethod]
public void TestDefaultMutations() {
  Foo foo = new Foo();
  DefaultAssert.IsDefault(foo.Name);
  DefaultAssert.IsDefault(foo.Description);
  DefaultAssert.IsDefault(foo.LastModified);

  foo.UpdateDescription("new description");
  DefaultAssert.IsDefault(foo.Name); // verify this wasn't mutated
  DefaultAssert.IsNotDefault(foo.Description); // this was *obviously* changed
  DefaultAssert.IsNotDefault(foo.LastModified); // this was a less obvious change.
}

DefaultAssert Are/Not

Are and AreNot methods of this kind aren't typical, in my experience. I wanted a quick way to assert against a bunch of fields or properties of the same type.

// Keep in mind the Foo from above.
[TestMethod]
public void DefaultCtor_MakesNameDescriptionDefault() {
  Foo foo = new Foo();
  DefaultAssert.AreDefault(new List<string> { foo.Name, foo.Description });
}
Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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
2.0.2 1,210 10/10/2017
2.0.1 944 10/10/2017

Adding multiple target frameworks.