[Feature] - dynamic assertions
See original GitHub issueBefore 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:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, you can pass in a
dynamic
object as the expectation. I’ve just tried that.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…