Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Mocking Controller Methods

Mocking Controller Methods

Scheduled Pinned Locked Moved C#
tutorialasp-netdesigntestingbeta-testing
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Liagapi
    wrote on last edited by
    #1

    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

    L M 2 Replies Last reply
    0
    • L Liagapi

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Liagapi wrote:

      can someone please point me to

      That is what Google was created for.

      L 1 Reply Last reply
      0
      • L Lost User

        Liagapi wrote:

        can someone please point me to

        That is what Google was created for.

        L Offline
        L Offline
        Liagapi
        wrote on last edited by
        #3

        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.

        Z L 2 Replies Last reply
        0
        • L Liagapi

          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.

          Z Offline
          Z Offline
          zequion
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • L Liagapi

            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.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            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)

            1 Reply Last reply
            0
            • L Liagapi

              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

              M Offline
              M Offline
              Member 12831772
              wrote on last edited by
              #6

              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

              L 1 Reply Last reply
              0
              • M Member 12831772

                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

                L Offline
                L Offline
                Liagapi
                wrote on last edited by
                #7

                Thank you for your response. It looks like I'll have to subscribe to pluralsight.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups