WithCustomMessage does not give a custom message when being used with IsTrue()
janvdpol opened this issue · 1 comments
janvdpol commented
Expected Behavior
The following line
Check.WithCustomMessage("It's false!").That(false).IsTrue();
should output "It's false"
Current Behavior
The following line
Check.WithCustomMessage("It's false!").That(false).IsTrue();
should output "expected [false] but was [true]" (or something similar)
Possible Solution
Workaround
Check.WithCustomMessage("It's false!").That(false).IsEqualTo(true);
This will output "It's false"
Code that reproduce the issue
....
Check.WithCustomMessage("It's false!").That(false).IsTrue();
...
Context
I have a method that's returning true or false, in case of a false i would like to provide more information why it is false.
Your Environment
- Version used: 2.6.0
- Framework version: Core 2.2
- Link to your project: -
dupdob commented
Thanks for reporting this issue with great details.
- I have been able to reproduce this issue and I confirm this is a bug (see explanation below)
- I will work on a fix and will publish a beta (with the fix) in the coming days
- As a workaround, you can use IsFalse and negating your condition. It will work as expected:
Check.WithCustomMessage("It's false!").That(!false).IsFalse();
Bug explanation: IsTrue is translated to Not.IsFalse (internally), and your issue revealed a bug in Not: any custom message is lost when using Not.