asp.net mvc - MVC Controller test using MOq -
I want to test the method given using Muke. How can I use my controller's moq objects? New objects are being created inside the controller method. There is a class datacontext and the second one is a concrete class. There is a problem in making a duplicate for these classes.
// My Controller class action method get public functionsTooled course (if cookie ["RememberUsername"] = null) {if (System.Web.HttpContext .Current.Cache.Get (userName) == faucet) {CacheUtil.UpdateCache (userName); } Dictionary & lt; String, int & gt; Classes of classes = (dictionary & lt; string, int & gt;) system. Web. Hpptex Present. Cache (User name); If (square platform. Value value (studio)) {var reference = new data syntax (datacontext); Var CoserPository = New course repository (reference); Bull student_exists = students axiom (stud); If (student_exists) {INMerelabel & lt; Course & gt; Course = Course Repository. GetRelated Courses (stuId); var userprofile = references Datacontext. UPS_Get UsprofileBustDude ID (Studio) .Oolist (); ViewBag.UserProfiles = User Profile; If (Course no. (=) == 0) {ViewBag.ErrorMessage = "No courses are available."; } See Return (Course); } See Return ("NostudentExistance"); }} See Return ("Noise"); } = "post-text" itemprop = "text"> Dependency injection and need to use a good IOC like NIC. If you want a unit test, the data objects inside your methods are not instantiated.
Comments
Post a Comment