.Net Interview Questions and Answers

Search:

MVC and .NET learning tutorials for components of MVC and how do you perform unit testing in MVC?

By : Shiv Prasad Koirala | May 31st, 2014 | Views : 2728 | Comments : 0 Bookmark and Share

Components of MVC: -


MVC consist of Model, View and Controller.


  • View represents UI of the application with which end user interacts.
  • Model represents the Business Data and business Logic
  • Controller handles the User Interaction logic.


Unit testing: -


Unit testing means to test each and every small logic in our code in an independent and automated manner. Also see tutorial video on .NET explaining practically on Simple Unit Testing: -



Performing unit testing in MVC: -


When we say logic there are different kinds of logic. Business Logic, Database logic, User Interaction Logic, Presentation logic and Data Transformation logic,


  • In MVC Model or Business Logic, is simply a class with some functions. So unit testing of it is not a big deal. It can be done easily using traditional class library unit testing approach.


  • User interaction logic resides in Controller which is also a simple class. It can be tested with no much effort.
    Click here to read more about controller unit testing

  • Database logic location will be different for different people. Some people put them in the Model whereas some consider it as a separate layer in an application. In either case it's going to be simple class library and hence falls under traditional class library unit testing.

  • Remaining is Presentation Logic and Data Transformation logic. Best example of presentation logic is displaying different controls in different colours based on some dynamic value. Data Transformation logic means, converting format of data to be displayed. Example we have DateOBirth and we want to display age.
    Such kind of logic always need to be written inside the view. Unit testing of view is not an easy thing.
    Solution is Implement ViewModel concept and take out these two logic from view and put it as a separate class.
    Once it become using class library unit testing approach we can test it.
    Learn more about View Model here.


For technical trainings on various topics like WCF, MVC, Business Intelligence, Design Patterns, WPF,TFS and Basic fundamentals feel free to contact SukeshMarla@Gmail.com or visit www.sukesh-marla.com


For more stuff like this click here. Subscribe to article updates or follow at twitter @SukeshMarla

 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
1 1 1 2 1
 
 
 
 

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

Article Categories

Learn in Hindi