❔ httpClient.PostAsync() - Program exits and never hits my breakpoint after?
This is the code:
When I step through the code with my debugger it gets as far as
var response...
and then the application exits.... It should get to the code below.
I don't know if this changes things but core is a class in a Class Library. I am using a Unit Test to run the test.
Sorry if this is a really stupid question but I'm stumped.![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1115757556783128777/image.png)
6 Replies
I have just realised that the Unit Test file was still called
Core.cs
- I changed the Unit Test class to CoreUT
to avoid any naming confusion. I've now renamed the .cs file and rebuilt the application but it's still exiting on the PostAsync()....![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1115761793558646944/image.png)
Ok not sure exactly what I did but it's working now... I changed the return in the function from
""
to the string symbol
andalso changed the unit test to use Assert.Equal()
. I can see it now gets past PostAsync()
and is now throwing an error due to response.EnsureSuccessStatusCode();
not returning 200.
I have to go to bed now but will leave this up as I'm not sure what I previously did wrong. Any advise would be great and I'll pick it up in the morning, thanks!Yeah, it's because you're calling register-agent in your test without awaiting it
Thank you but I haven't changed that and now it's working? 🤔
exactly, in this case put a breakpoint on the line after the await
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.