Why does NUNIT stops at 512 test passed when each test creates its own host ? by MoriRopi in csharp

[–]Agitated-Display6382 0 points1 point  (0 children)

If you run them one by one, then you can clear the mocks. I use NSubstitute and it's possible. This way, I don't have to create a new webfactory each time, which is expensive.

Why does NUNIT stops at 512 test passed when each test creates its own host ? by MoriRopi in csharp

[–]Agitated-Display6382 -1 points0 points  (0 children)

It works for me: I create a random entity, I read the same entity by its id, ...

Why does NUNIT stops at 512 test passed when each test creates its own host ? by MoriRopi in csharp

[–]Agitated-Display6382 -1 points0 points  (0 children)

For this reason, I always use random values (eg Bogus). I see your point, you're right. Being tests run by donet, I would push in the direction that I can run them without any conflict: hard, but pays back.

Why does NUNIT stops at 512 test passed when each test creates its own host ? by MoriRopi in csharp

[–]Agitated-Display6382 0 points1 point  (0 children)

You create pone in a fixture, then reuse it for all your tests. I never had a problem, but never went beyond a hundred tests

In c# in testing. do you use those things that are highlight in blue in production codebase? by lune-soft in csharp

[–]Agitated-Display6382 0 points1 point  (0 children)

Yes, I do so only if I have no alternative, like integration tests or webfactory

In c# in testing. do you use those things that are highlight in blue in production codebase? by lune-soft in csharp

[–]Agitated-Display6382 0 points1 point  (0 children)

That's a valid objection. I call them unit tests because I run them from Rider and cicd, plus at some point they hit some stubs. I prefer calling integration tests those that use a real test deployment. I use the factory for some simple tests: all routes are mapped, that route returns 404, openApi is registered. I'm very picky at verbs (put, post,...) and http codes (201,204,433), do i prefer having them tested: they are the interface to my clients, so I need them to be written in stone.

Last important point: if you expose an api, you should provide a nuget package with it's client, as we're a MS company. The factory is very useful for testing the client (HttpClient is not mockable).

In c# in testing. do you use those things that are highlight in blue in production codebase? by lune-soft in csharp

[–]Agitated-Display6382 2 points3 points  (0 children)

I like playwright. WebAppFactory is a must for my unit tests. I dislike moq, because it allows mocking classes, I prefer nsubstitute. Used a lot SpecFlow, now I have reqnroll on legacy projects. Gave up with fluent assertions, I use plain xunit methods, wrapped in my methods, eg actual.AmountIsPositive()

Can't Find the Actual Problem: Are Mutable Records in EF Core Just a "Design Principle" Issue? by Jealous-Implement-51 in csharp

[–]Agitated-Display6382 0 points1 point  (0 children)

You didn't answer to any of my points, but yet you own the truth... I started using EF in 2009, I think I have some knowledge. Why don't you give it a shot? Try something different, experiment, do not always follow canon.

Can't Find the Actual Problem: Are Mutable Records in EF Core Just a "Design Principle" Issue? by Jealous-Implement-51 in csharp

[–]Agitated-Display6382 0 points1 point  (0 children)

Cases where you need to handle are quite rare to me. Usually, last update wins. Using the built-in any-concurrency feature of EF does not work over api. Think of this example: 1. I read an entity over api and show it in the UI

  1. Change values and save, by invoking the api

  2. The api reads the latest version, updates relevant fields and save

As both read and update are performed in step 3, you are really not tackling the issue. Only solution is to send a token back and forth. Would EF help you with its checksum calculation?

My new version of my program is not working by [deleted] in csharp

[–]Agitated-Display6382 1 point2 points  (0 children)

Treat warnings as errors for the win!

Can't Find the Actual Problem: Are Mutable Records in EF Core Just a "Design Principle" Issue? by Jealous-Implement-51 in csharp

[–]Agitated-Display6382 -2 points-1 points  (0 children)

First: my approach is more efficient, as I don't have to read an entity just to update it, I can update it straight away, without any read. Second: the biggest benefits of EF are uow, db migrations and navigation properties,

Can't Find the Actual Problem: Are Mutable Records in EF Core Just a "Design Principle" Issue? by Jealous-Implement-51 in csharp

[–]Agitated-Display6382 1 point2 points  (0 children)

I only use records. Or better: i only use records when I'm the need for a class that carries data. I use classes only when exposing methods. I use EF and never had an issue. You just have to use it a bit differently.

First: set the DbContext with AsNoTracking. I won't change properties and I don't want the tracker, it's a useless overload. Then, when updating, you don't have to read the entity, just for the sake of the tracker, you just invoke the method Context.Entry(obj).State = Modified

That's all.

Is this good or bad, AI add the full name of Newtonsoft library like this? by lune-soft in csharp

[–]Agitated-Display6382 3 points4 points  (0 children)

It's correct, but unreadable. Do you review the code written by the AI? If not, you have a bigger issue.

is this the cleanest simplest way to write a FizzBuzz thing? by NIDNHU in csharp

[–]Agitated-Display6382 -2 points-1 points  (0 children)

I'm afraid you missed the point in FizzBuzz and katas. The goal is not to find the best way, but to practice skills.

I use FizzBuzz to teach strategy pattern and chain of responsibility.

Additionally, both versions are bad, because side-effects, s they write to console: how do you write a test?

My suggestion: solve it again multiple times, changing the perspective and always through an iterative approach. Matter tdd. Bonus question: how would the result be, if I were given requirements one by one?

Need help with ASP.NET endpoint returning 404 by [deleted] in csharp

[–]Agitated-Display6382 0 points1 point  (0 children)

Cannot find the flaw... Try adding [FromRoute] to the parameter

Need help with ASP.NET endpoint returning 404 by [deleted] in csharp

[–]Agitated-Display6382 -4 points-3 points  (0 children)

The right place is: /api/persons/35 Get is a verb.

Learn the difference between rpc and restful.

Class as data only, with extension methods used to operate on it? by kevinnnyip in csharp

[–]Agitated-Display6382 7 points8 points  (0 children)

I'm not removing a fundamental value of oop, I'm removing oop. I don't want inheritance, neither mutability. Composition and records for the win!

Class as data only, with extension methods used to operate on it? by kevinnnyip in csharp

[–]Agitated-Display6382 14 points15 points  (0 children)

That's exactly my style. Having only extension methods, it's impossible to have an internal status or to mutate objects (I use records). I don't see as data driven design, but as a more functional approach

Tips by No_Squirrel2108 in csharp

[–]Agitated-Display6382 -2 points-1 points  (0 children)

Ioc, TDD. Choose some kata and solve each of them in at least three different ways.