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.

FakeItEasy.FluentAssertions package

See original GitHub issue

Maybe this is too much overhead for a simple benefit but I’m dumping it here anyway as an idea. Just thought it might be cool to support fluent assertions which would allow to use their exception and assertion model. The one could use:

A.CallTo().Should().HaveHappened().And.ExactlyOnce()

This would also help to spread the usage of FluentAssertions

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:17 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
adamralphcommented, Mar 22, 2017

Leaving it to the community to spin up a package for this, if desired.

0reactions
thomaslevesquecommented, Mar 13, 2017

Well, it’s fairly easy to get the basic features (MustHaveHappened/MustNotHaveHappened) working:

public static class FakeItEasyFluentAssertionsExtensions
{
    public static FakeItEasyCallAssertions Should(this IAssertConfiguration configuration)
    {
        return new FakeItEasyCallAssertions(configuration);
    }
}

public class FakeItEasyCallAssertions : ReferenceTypeAssertions<IAssertConfiguration, FakeItEasyCallAssertions>
{
    private IAssertConfiguration _configuration;
    
    public FakeItEasyCallAssertions(IAssertConfiguration configuration)
    {
        _configuration = configuration;
    }
    
    protected override string Context
    {
        get { return "call"; }
    }
    
    public void HaveHappened(Repeated repeatConstraint = null)
    {
        _configuration.MustHaveHappened(repeatConstraint ?? Repeated.AtLeast.Once);
    }
    
    public void NotHaveHappened()
    {
        _configuration.MustNotHaveHappened();
    }
}

...

A.CallTo(() => foo.Bar(42)).Should().HaveHappened(Repeated.Exactly.Twice);

That being said, I’m not sure it’s worth the trouble…

👍 to close as wontfix

Read more comments on GitHub >

github_iconTop Results From Across the Web

FluentAssertions.ArgumentMatchers.FakeItEasy 0.1.0
Contains FakeItEasy argument matchers using FluentAssertions. ... dotnet add package FluentAssertions.ArgumentMatchers.FakeItEasy --version ...
Read more >
Exceptions
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 >
Assertion
When FakeItEasy records a method (or property) call, it remembers which objects were used as argument, but does not take a snapshot of...
Read more >
FakeItEasy vs Fluent Assertions - compare differences and ...
Compare FakeItEasy vs Fluent Assertions and see what are their differences. ... NPM package 'ua-parser-js' with more than 7M weekly download is compromised....
Read more >
Using FakeItEasy for mocking and stubbing for unit ... - YouTube
... that we will unit test 02:42 - NuGet package for FakeItEasy 03:06 ... How To Unit Test CQRS Handlers With Moq And...
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