question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extend BooleanAssertions with Implies

See original GitHub issue

Description

Add logical implication to the available boolean assertions.

That is, a.Should().Imply(b) asserts that a → b.

This would be useful in asserting, for example, that object equality implies hash-code equality without additional logic and a better built-in “because”.

Complete minimal example

Looking for something like this.

[DataTestMethod]
[DataRow(false, false)]
[DataRow(false, true)]
// failure case: [DataRow(true, false)]
[DataRow(true, true)]
public void A_Implies_B(bool a, bool b) => a.Should().Imply(b);

Note this is logically equivalent to !a || b.

Additional Information

Also volunteering to add this.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:21 (21 by maintainers)

github_iconTop GitHub Comments

3reactions
dennisdoomencommented, Apr 12, 2022

This is where my lack of CS degree shows 😉

1reaction
dennisdoomencommented, Jan 1, 2023

Ok I see. Unfortunately this param has to be optional.

Ah, I see now. So yes, I agree with @jnyrup

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the purpose of "extends boolean" in Typescript?
declare function f<T extends boolean>(x: T): T extends true ? string : number; // Type is 'string | number' let x = f(Math.random()...
Read more >
Booleans
A very extensive set of extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style unit...
Read more >
Assertions (JUnit 5.0.1 API)
Asserts that the boolean condition supplied by booleanSupplier is not true . static void, assertFalse(boolean condition, Supplier<String> messageSupplier).
Read more >
Assertions (AssertJ fluent assertions 3.18.1 API) - javadoc.io
Modifier and Type Method Description static Condition allOf​(Iterable> conditions) Creates a new AllOf static Condition allOf​(Condition... conditions) Creates a new AllOf static Condition anyOf​(Iterable> conditions) Creates...
Read more >
Junit Assert & AssertEquals with Example
Assert which extends java.lang.Object class. There are various types of assertions like Boolean, Null, Identical etc.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found