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.

[Feature] - dynamic assertions

See original GitHub issue

Before you file a bug, have you:

  • Tried upgrading to newest version of Fluent Assertions, to see if your issue has already been resolved and released?
  • Checked existing open and closed issues, to see if the issue has already been reported?
  • Tried reproducing your problem in a new isolated project?
  • Read the documentation?
  • Considered if this is a general question and not a bug?. For general questions please use StackOverflow.

Description

It would be great if asserting dynamic types could work. Especially dynamicObj.Should().BeAssignableTo<MyClass>(); would be perfect (inclusive dealing with a MyClass-object afterwards).

Expected behavior:

dynamic obj = MaybeAnAPICallWhichReturnsDynamic();

obj.Should()
    .BeAssignableTo<MyClass>()
    .Which
    ....

Actual behavior:

Test fails with “MyClass does not contain a definition for ‘Should’”

Versions

  • Which version of Fluent Assertions are you using? 6.2.0
  • Which .NET runtime and version are you targeting? .NET Core 3.1.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dennisdoomencommented, Nov 28, 2021

Yes, you can pass in a dynamic object as the expectation. I’ve just tried that.

0reactions
kelpscommented, Nov 27, 2021

I didn’t intend to add the extension to a dynamic. The main object isn’t dynamic in my example. I intended to pass a dynamic as parameter to BeEquivalentTo (inside my custom assertion), but the main object is a real reference type, that would be compared to a dynamic, instead of an anonymous. That should be possible…

Read more comments on GitHub >

github_iconTop Results From Across the Web

17.4. Introduction to Dynamic Assertions
Inside the assert() method, we can get the currently logged in user and compare it with the user passed, this way we can...
Read more >
Best practices for assertions
Use variables to create dynamic assertions · Record the steps to create a new order. · Extract the order ID number from the...
Read more >
how to use dynamic assertion method name?
This is so that I can have a map from selector to function, in order to iterate over it and check whether some...
Read more >
How to Add assertion in dynamic Response
Hi, i need to add assertion with parametarized value. ... Based on the nature of test,you should use either the Pro feature (Data...
Read more >
Import assertions
The new import assertions feature allows module import statements to include additional information alongside the module specifier.
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