Skip to content

Releases: feO2x/Light.GuardClauses

v1.2.0

25 Jul 12:55

Choose a tag to compare

Ten more assertions methods:

  • ComparableAssertions:
    • MustBeGreaterThan
    • MustBeGreaterThanOrEqualTo
    • MustBeLessThan
    • MustBeLessThanOrEqualTo
  • EnumerableAssertions
    • MustNotEndWith
    • MustEndWith
    • MustStartWithEquivalentOf
    • MustEndWithEquivalentOf
    • MustNotStartWithEquivalentOf
    • MustNotEndWithEquivalentOf

v1.1.0 Never forget COMPILE_ASSERTIONS any more

02 Jun 21:17

Choose a tag to compare

Added features

  • COMPILE_ASSERTIONS symbol is now set when NuGet package is installed...
  • ...and removed when package is uninstalled
  • EnumerableAssertions.MustNotStartWith

Stabilized

01 Jun 07:31

Choose a tag to compare

Added features:

  • EnumerableExtensions
    • MustHaveMinimumCount
    • MustHaveMaximumCount
    • MustStartWith for collections
  • NotNull
    • added helper methods to easily convert from Interface types and back (because implicit conversion from or to Interface types are not allowed in C#)

Performance testing:

  • MustNotBeNull is ca. 65% to 70% as fast as the imperative version, FluentAssertions is about 1% (in Microbenchmark)
  • But in Macrobenchmark, it doesn't matter which implementation is used - Light.GuardClauses probably has the highest performance impact in setter methods or similar methods where only few assignments are made

Learn to walk

29 Mar 10:39

Choose a tag to compare

Added features:

  • CommonAssertions:
    • MustBeSameAs and MustNotBeSameAs
  • StringAssertions:
    • MustHaveLength
    • MustStartWith and MustNotStartWith
    • MustStartWithEquivalentOf and MustNotStartWithEquivalentOf
    • MustEndWith and MustNotEndWith
    • MustEndWithEquivalentOf and MustNotEndWithEquivalentOf
    • MustContainOnlyLetters
    • MustContainOnlyLettersAndDigits
  • EnumerableAssertions:
    • MustHaveCount
  • DictionaryAssertions:
    • MustContainValue and MustNotContainValue
    • MustContainValues and MustNotContainValues
    • MustContainPair and MustNotContainPair

Changes:

  • MustHaveNoDuplicates name changed to MustNotContainDuplicates.
  • New way of specifying tests for custom messages and custom exceptions.
  • Instead of exception objects, delegates are now passed to raise custom exceptions.
  • Custom messages are not used internally to reduce the number of objects created per call.
  • Custom exceptions do not replace ArgumentNullExceptions any longer when MustNotBeNull is called internally.
  • Renamed DictionaryAssertions:
    • MustContainKey
    • MustNotContainKey
    • MustContainKeys
    • MustNotContainKeys

Hello Light.GuardClauses

23 Mar 16:52

Choose a tag to compare

First version of Light.GuardClauses

Includes the following functionality:

  • Check: CompileAssertionsSymbol and methods That and Against as minimal functionality for creating assertions that can be selectively compiled.
  • CommonAssertions: MustNotBeNull (probably the most important one), MustBeNull, MustBeType, MustHaveValue, MustNotHaveValue, MustBeValidEnumValue, and MustNotBeEmpty for GUIDs
  • ComparableAssertions: MustNotBeLessThan(OrEqualTo), MustNotBeGreaterThan(OrEqualTo), MustBeIn and MustNotBeIn for ranges
  • DictionaryAssertions: MustBeKeyOf, MustNotBeKeyOf, MustHaveKey(s), MustNotHaveKey(s)
  • EnumerableAssertions: MustBeOneOf, MustNotBeOneOf, MustNotBeNullOrEmpty, MustHaveNoDuplicates, MustNotContainNull, MustContain, MustNotContain, MustBeSubsetOf
  • EqualityAssertions: MustBe, MustNotBe, MustBeEqualTo and MustNotBeEqualTo for IEquatable instances, MustBeEqualToValue and MustNotBeEqualToValue for IEquatable instances that are value types
  • NotNull: a struct holding a reference to an instance of a reference type and ensures that this reference is not null. Overrides Equals and GetHashCode so that it behaves exactly as the referenced object in this regard (calls are forwarded). Overloads several version fo the == and != operators and provides implicit conversion so that it is easy to use. If you use this struct on a parameter, you can definitely be sure that the reference is not null, but there might be some other issues with the usage of this type (e.g. when resolving via a DI container). As it is a struct, there should be minimal performance overhead and no pressure on the garbage collector as no new object is created when this type is used.