x.Should().NotBeNull().And.Subject returns object rather than the type of x
See original GitHub issueIt turns out that x.Should().NotBeNull().And
returns ObjectAssertions
having its Subject
of type object
rather than of x
. So you can’t nest assertions.
Foo foo = new Foo();
AndConstraint<ObjectAssertions> c = foo.Should().NotBeNull();
ObjectAssertions a = c.And;
object s = a.Subject; // here I'd expect Foo
How can it be enhanced?
Issue Analytics
- State:
- Created 9 years ago
- Comments:19 (18 by maintainers)
Top Results From Across the Web
fluentassertions C# I Don't understand Should().NotBeNull()
I have read through fluentassertions.com and still confused as to what happens if a var is null or not null. so for instance...
Read more >Tips - Fluent Assertions
BeTrue() , there is most likely a better way to write it. By having Should() as early as possible in the assertion, we...
Read more >Fluent Assertions - RSSing.com
object theObject = null; theObject.Should().BeNull("because the value is null"); theObject = "whatever"; theObject.Should().BeOfType< ...
Read more >Terms Aggregation Usage | Elasticsearch.Net and NEST
A multi-bucket value source based aggregation where buckets are dynamically built - one per unique value. See the Elasticsearch documentation on terms ...
Read more >Objects (Java SE 17 & JDK 17)
Returns the first argument if it is non- null and otherwise returns the non- null value of supplier.get() . Type Parameters: T -...
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
In case you want to prevent “possible NullReferenceException” warnings, this may help.
Example usage:
I wish I could use this API in strongly-typed manner so could access subject’s properties, e.g.: