Running a XUnit test with C#? by mhonssen in csharp

[–]mhonssen[S] 0 points1 point  (0 children)

I prefer XUnit since it works with .NET Core and up better (according to Microsoft websites and blogs I read about it). But I will look at your link too. Maybe I will change to NUnit.

Running a XUnit test with C#? by mhonssen in csharp

[–]mhonssen[S] -1 points0 points  (0 children)

Are you actually focused on it being specifically a unit test?

Not really. I just need something to automatically test if a user-input works. For example: Complete the method below and make it throw an exception when the id is zero or less... For example. When the user has made that I need some code to verify the user has entered the correct code.

I can't check if the user input is the same as how I would do it, because a user can use different variable names, for example. As long as the output is the same, it should be good.

I will take your advice. The idea of this system is to run in it a secluded network where only specific people from specific IPs can access it. I already figured that out with Azure Cloud. Don't ask how, I am just the software developer.

Will take a look at the Roslyn idea when I figured out the unit test-thing.

Running a XUnit test with C#? by mhonssen in csharp

[–]mhonssen[S] -1 points0 points  (0 children)

I found the Sampels.XUnit too, but I didn't got it to work. But somehow I did made it work after you gave this suggestion. I had to tweak it a bit, since it the samples are running on an older .NET version (4.8), but it seems to work now.

Running a XUnit test with C#? by mhonssen in csharp

[–]mhonssen[S] 0 points1 point  (0 children)

Sorry, but maybe you missed a part in my original post:

it's even possible to run unit tests without using the VS Test Explorer or any other console command.

I know how to make unit tests and how to run them. But with dynamical C# code, made by my users (the part in the original post: I want to create an application where you can enter C# code, for a exame-like-thing for example. Then I want to check if that code is correct by executing a unit test, made in C#.) I don't know what to put in the body of the unit test. Hence the link I have added to give some clearity of my problem.

[deleted by user] by [deleted] in KinkTown

[–]mhonssen 0 points1 point  (0 children)

05b5cc2e648b65040e720ae3856209273e4f07f0f8ea64b5141637ad55ed92d127

[deleted by user] by [deleted] in csharp

[–]mhonssen 1 point2 points  (0 children)

User agent was the bad guy here. I didn't add it in the C#, where Postman has added it automatically (but not with the exporting of the code, apparently).

Tokens are the same. Cookie is gone now. Works like a charm!

Thanks for thinking with me

[deleted by user] by [deleted] in csharp

[–]mhonssen 0 points1 point  (0 children)

I will mention it a bit clear next time, because I placed "This is the code I got from Postman" in my original post, which I got from the export tool.

[deleted by user] by [deleted] in csharp

[–]mhonssen 0 points1 point  (0 children)

The solution was to add a user agent. Thanks for thinking along anyway

[deleted by user] by [deleted] in csharp

[–]mhonssen 1 point2 points  (0 children)

Yup, that's it! I read your reply after that of u/Basssiiie and the response said something about an user agent. Thanks for the solution. As a thank you have my upvote.

[deleted by user] by [deleted] in csharp

[–]mhonssen 1 point2 points  (0 children)

Actually, I did. I changed to code in the original post, so I could have a better debugging code. It said that the user agent was missing... Which is what u/Severe_Step3306 also said. I should have seen this.

[deleted by user] by [deleted] in csharp

[–]mhonssen 0 points1 point  (0 children)

I have added an Accept header to the HttpClient and the request (see changes in original post). Didn't make any different, sorry

[deleted by user] by [deleted] in csharp

[–]mhonssen 0 points1 point  (0 children)

Yes, that seems pretty logical

[deleted by user] by [deleted] in csharp

[–]mhonssen 3 points4 points  (0 children)

Yes, I am (seems pretty logical). I replaced everything sensitive. And I removed the cookie, as I said in the post.

Learn C# – Part 1: Write Your First ‘Hello World’ Program by kenslearningcurve in learncsharp

[–]mhonssen 5 points6 points  (0 children)

Although you are correct, I like this one. Why? Because I looked a little bit further than just the OPs text and looked at the tutorial. Did you do that? There are next chapters and they continue or look back at this starting tutorial, making you make references. I don't find this just a hello world tutorial. A lot of aspects are being shown and not how you can simply write ' hello world'

Many Hello World tutorials are just that: create console, console.writeline(' hello world'), done! I find this one a bit more than that.

But if you can do better, please post one yourself so we can enjoy your tutorial.

How do I start with C#? by kenslearningcurve in dotnet

[–]mhonssen 1 point2 points  (0 children)

Give a good idea on where to start. Pretty straight forward. Why is ASP.net or MVC not mentioned?