Pibbles
Pibbles
Explore posts from servers
CC#
Created by Pibbles on 9/15/2023 in #help
Unit Testing Classes with Dependency Injection (ASP.NET Core)
How do you guys usually handle this? I saw some people mock every single injection which seems pretty horrible, other people end up in a way where they effectively have to rebuild the Program.cs class in their test project. I'm using xUnit To be a little more clear. The class I want to test on takes in some interfaces via dependency injection in it's constructor, and these are used in the methods I want to test. - Ideally, I want them to function how they actually would, using the concerete classes injected
66 replies
CC#
Created by Pibbles on 9/15/2023 in #help
What mock libraries are people using?
I know a bunch of people stopped using moq, so what are they using now?
7 replies
CC#
Created by Pibbles on 8/29/2023 in #help
❔ File naming convention preference
In VS, the I have a folder for ReadModels and another for WriteModels. I then have a file in each for User. Would you name this file User.cs or ReadUserModel.cs (/Write). User.cs is simpler and nicer, but then the VS tabs for your files all just say User.cs, and I have to click in to know what actual file that is. So which way do you go? I know I can also get an extension to change this header name, let me know if you do that too
17 replies
CC#
Created by Pibbles on 8/20/2023 in #help
❔ ASP .NET Core Controller Default Route Issue
I have a controller (TestController) with an Index action method. The url I'm using is "localhost:8372/Test" This returns a 404 error If I add [Route("[controller]")] the controller works as expected. I just created the application but I thought that [Route("[controller]")] was the default route. Is it not?
14 replies
CC#
Created by Pibbles on 8/16/2023 in #help
Visual Studio project reference not updating with new code
Basically I have 2 projects in separate solutions, API and Data (the projects) API usually references a package for the Data project, but I've removed that, and added my local Data project as a reference in both the API solution and project. But when I go through the API project, on parts where it's "using Data.Models", if I step into the classes, they aren't my local classes. It takes me to some CompilerGenerated class model when stepping into the Data.Models stuff
16 replies
CC#
Created by Pibbles on 5/17/2023 in #help
❔ Entity Framework Migrations
So I deleted a migration or 2, which I've come to learn from the docs was a bad move. The migrations I deleted were all the top of the list (ie most recents) but my context snapshot and migrations are out of sync now. Is there a way I can run through those migrations, and create a context snapshot from them? I'm pretty sure there's a way to create code from a db, and you can create a db from the migrations, so there must be a way...
7 replies
CC#
Created by Pibbles on 3/4/2023 in #help
❔ How do VS solutions work and CLI
Basically I wanna learn more about how a solution in VS actually works, I've made many applications with it but if you ask me about what the hell the .proj file is I'd be lost, and if you asked me to setup the solution with just CLI I'd probably start crying. I just need some links/pointers to where I can learn this stuff, the inner workings of it all
6 replies