Mocking Controller Methods
-
Hi, can someone please point me to a tutorial on unit testing MVC controller code that implements dependency injection, Repository and Unit of Work design patterns. In particular I would like to learn how to do Mocking. Thanks
-
Hi, thanks for replying. I already looked for the past couple of days, I did not find any that talked about all three concepts (Dependency Injection, Repository and Unit of Work, and Mock) in the same tutorial. I have seen tutorials on unit testing MVC controller methods but they were lacking what I'm looking for. None of them were using Dependency Injection or Mocking.
-
Hi, thanks for replying. I already looked for the past couple of days, I did not find any that talked about all three concepts (Dependency Injection, Repository and Unit of Work, and Mock) in the same tutorial. I have seen tutorials on unit testing MVC controller methods but they were lacking what I'm looking for. None of them were using Dependency Injection or Mocking.
Focusing and exposing this topic is difficult. 1.- I have some functions in .cs files that I use in both Main and functions .cs and DLLs. These functions use a structure with some variables of general use. In order to compile those functions for the Main or if I want to create a dll, the structure must exist for functions such as in a .cs file. Imagine that in the cs the structure is called Name_Common.Cls_Common.StCommon 2.- When using Main, I need to add the definition of that structure of the same .cs That already produces the mentioned error of ambiguity. But if I want with an alias to refer to the structure of the dlls, I have to enter the variables every time from Main in each structure of each dll, being in Main with alias: using Name_Common_Main = Dll.Name_Common for the first dll. But, and for the second dll? I can not add another using or if? And those variables, when they are not global, when they change their value will not be updated. I'm stuck, mentally and by software. How do people do?
-
Hi, thanks for replying. I already looked for the past couple of days, I did not find any that talked about all three concepts (Dependency Injection, Repository and Unit of Work, and Mock) in the same tutorial. I have seen tutorials on unit testing MVC controller methods but they were lacking what I'm looking for. None of them were using Dependency Injection or Mocking.
Liagapi wrote:
I did not find any that talked about all three concepts (Dependency Injection, Repository and Unit of Work, and Mock) in the same tutorial.
There are a lot of concepts and patterns. It is impossible to create tutorials for each possible combination thereof, and so there's a big chance it does not exist.
Liagapi wrote:
they were lacking what I'm looking for. None of them were using Dependency Injection or Mocking.
Tutorials usually focus a single concept to explain that, without adding stuff that might distract from it. Find a tutorial on each concept, and combine that knowledge.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)
-
Hi, can someone please point me to a tutorial on unit testing MVC controller code that implements dependency injection, Repository and Unit of Work design patterns. In particular I would like to learn how to do Mocking. Thanks
There is a good tutorial at plural sight. WPF and MVVM: Test Driven Development of ViewModels | Pluralsight[^] The content walks through how to use Moq framework to mock objects
-
There is a good tutorial at plural sight. WPF and MVVM: Test Driven Development of ViewModels | Pluralsight[^] The content walks through how to use Moq framework to mock objects