Skip to content

JayBazuzi/ValueTypeAssertions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

cffb783 · Jul 13, 2019

History

64 Commits
Jul 13, 2019
Jul 13, 2019
May 13, 2016
May 15, 2016
May 15, 2016
May 13, 2016
May 30, 2016
May 15, 2016
May 15, 2016
May 15, 2016
May 13, 2016
May 14, 2016
May 15, 2016
May 15, 2016

Repository files navigation

Build status

Available on NuGet

ValueTypeAssertions

By "value type", I mean "a type that represents a value in some domain." Two of these objects are equal if they have the same value.

To correctly implement this in .Net is tricky. There's object.Equals() and operator == and GetHashCode() and more. These are assertions that ensure that you have checked all the checkboxes in implementing equality.

You can use it like this:

class NtfsPath
{
  // implementation here
}

[Test]
public void NtfsPathHasValueEquality()
{
  ValueTypeAssertions.HasValueEquality(new NtfsPath("foo.txt"), new NtfsPath("foo.txt"));
  ValueTypeAssertions.HasValueInequality(new NtfsPath("foo.txt"), new NtfsPath("bar.txt"));
}

[Test]
public void NtfsPathIsCaseInsensitive()
{
  ValueTypeAssertions.HasValueEquality(new NtfsPath("foo.txt"), new NtfsPath("FOO.TXT"));
}

Acknowledgements

99% of the ideas in this project came from other people. A big chunk came from Brian Geihsler.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published