-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ResultsOfTGenerated tests #57465
Conversation
@@ -72,7 +72,7 @@ Results<ChecksumResult1, NoContent> MyApi() | |||
// Act & Assert | |||
var result = MyApi(); | |||
|
|||
Assert.ThrowsAsync<ArgumentNullException>(async () => | |||
await Assert.ThrowsAsync<ArgumentNullException>(async () => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kind of surprised there isn't an analyzer for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is now, which is why we noticed this.
See #57303
@@ -84,7 +84,7 @@ public void ResultsOfTResult1TResult2_Throws_InvalidOperationException_WhenResul | |||
// Arrange | |||
Results<ChecksumResult1, NoContent> MyApi() | |||
{ | |||
return new ChecksumResult1(1); | |||
return (ChecksumResult1)null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I reading correctly that the test was looking for an argument null exception but the argument wasn't null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, although it throws an InvalidOperationException
because the null value here is not an argument but the return type of a method we've indicated cannot be null.
@@ -482,7 +482,7 @@ static void GenerateTest_ExecuteResult_ExecutesAssignedResult(StreamWriter write | |||
static void GenerateTest_Throws_ArgumentNullException_WhenHttpContextIsNull(StreamWriter writer, int typeArgNumber) | |||
{ | |||
//[Fact] | |||
//public void ResultsOfTResult1TResult2_Throws_ArgumentNullException_WhenHttpContextIsNull() | |||
//public async Task ResultsOfTResult1TResult2_Throws_ArgumentNullException_WhenHttpContextIsNull() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this sample test need the (ChecksumResult1)null
change too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily. This one is testing the exception that is thrown when no HTTP context is provided (ref) which happens before we asset on the IResult
type being null.
Closes #57360.