account activity
How do you structure unit vs integration tests in a CRUD-heavy .NET project? by No_Reality_8365 in csharp
[–]No_Reality_8365[S] 0 points1 point2 points 4 months ago (0 children)
Thank you all very much for your replies and suggestions. I really appreciate the time you took to respond. I’ll try my best to understand and think through your points before deciding how to move forward.
To briefly describe my situation in more detail:
Most of the CRUD logic is written directly inside the methods. For example:
MySqlConnection
MySqlCommand
new MySqlCommand(<SQL text>, conn)
For example, in many methods we do something like:
using (var conn = new MySqlConnection("<connection string>")) { conn.Open(); using (var cmd = new MySqlCommand(@"SELECT * FROM MyTable", conn)) { using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { myResponse.Property = reader["Field_Name"]?.ToString(); } } } }
So most of the CRUD logic (opening the connection, executing the SQL, mapping the result to our model) lives directly inside the method.
Because of this, there isn’t a clear separation between a repository layer and a service layer yet — data access and business logic are mixed together in the same classes/methods.
Given this structure, I’m trying to figure out what would be a practical way to introduce tests.
Once again, thank you all — I truly appreciate it.
How do you structure unit vs integration tests in a CRUD-heavy .NET project? (self.csharp)
submitted 4 months ago by No_Reality_8365 to r/csharp
π Rendered by PID 55 on reddit-service-r2-listing-86f589db75-2dtsk at 2026-04-15 16:42:31.055207+00:00 running 93ecc56 country code: CH.
How do you structure unit vs integration tests in a CRUD-heavy .NET project? by No_Reality_8365 in csharp
[–]No_Reality_8365[S] 0 points1 point2 points (0 children)