Can NotBeNull() keep the property type? #1748
-
Hey guys 👋🏻 The following code does not compile at the moment: var testee = new HttpResponseMessage(HttpStatusCode.Accepted);
testee.Should().NotBeNull().And.Subject.StatusCode.Should().Be(HttpStatusCode.Accepted); Is it somehow possible that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Because of limitations of the compiler, we cannot define a generic There's a rather ugly workaround:
But my recommendation is to replace this call with:
|
Beta Was this translation helpful? Give feedback.
Because of limitations of the compiler, we cannot define a generic
Should
extension method onT
and still have more specific extension method for types likeIEnumerable<T>
, etc. That's why your example is using the non-genericObjectAssertions
.There's a rather ugly workaround:
testee.Should().NotBeNull().And.Subject.As<HttpResponseMessage>().StatusCode.Should().Be(HttpStatusCode.Accepted);
But my recommendation is to replace this call with: