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.

Chained ordered assertions

See original GitHub issue

E.g.

A.SequenceOfCalls(
    A.CallTo(() => fake.Bar(2)).MustHaveHappened(),
    A.CallTo(() => fake.Bar(1)).MustHaveHappened());

…with, perhaps, a better method name.

@blairconrad has proved that this can work simply by adding syntactic sugar to the A class.


update

The new syntax will be:

A.CallTo(() => fake.Bar(3)).MustHaveHappened(Repeated.Exactly.Twice)
    .Then(A.CallTo(() => fake.Bar(2)).MustHaveHappened())
    .Then(A.CallTo(() => fake.Bar(1)).MustHaveHappened());
  • Remove #602 from the 2.0.0 milestone and label wontfix

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:77 (71 by maintainers)

github_iconTop GitHub Comments

2reactions
adamralphcommented, Apr 4, 2016

I think idiomatic English would be:

// A call to "fake.Bar(2)" must have happened and then
// a call to "fake.Bar(1)" must have happened.

so I’m wondering if this would this be possible:

A.CallTo(() => fake.Bar(2)).MustHaveHappened(Repeated.Exactly.Twice)
    .AndThen(A.CallTo(() => fake.Bar(1)).MustHaveHappened());
1reaction
cecilphillipcommented, Mar 31, 2016

A.OrderedSequence ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ordered assertions
Using FakeItEasy you can assert that calls happened in a specific order on one or more fake objects. Details. One area where ordered...
Read more >
Chained assertions - A crust of code
The assertions that are about the same data structure are clearly grouped together. · The two important functions are clearly visible at the...
Read more >
c# - Chained Assertions
I use Code Contracts to take care of my assertions. Contract.Requires(customer.Age > 0); Contract.Requires(!string.
Read more >
Chained AssertJ assertions should be simplified to the ...
This rule reports an issue when an assertion can be simplified to a dedicated one. The array below gives a non-exhaustive list of...
Read more >
Weird evaluation order in chained functions - c++
My question : is it a compiler bug, or the evaluation order between chained calls is not guaranteed in this case ? Is...
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