ASP.NET
  Home arrow ASP.NET arrow Page 3 - Disadvantages of the ASP.NET MVC Framework
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Disadvantages of the ASP.NET MVC Framework
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 8
    2008-11-25

    Table of Contents:
  • Disadvantages of the ASP.NET MVC Framework
  • The Second Disadvantage
  • Category Method
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Disadvantages of the ASP.NET MVC Framework - Category Method


    (Page 3 of 4 )


    Next, let’s take a look at the unit test related to the Category method, as follows:

    //…… (omitted)

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using MvcApplication.Controllers;

    using MvcApplication.Models;

    using System.Web.Mvc;

    using System.Web.Routing;

    using Moq;

    namespace MvcApplicationTest

    {

    [TestClass()]

    public class ProductsControllerTest

    {

    [TestMethod]

    public void Category()

    {

    var categories = new List<Category>();

    categories.Add(new Category { CategoryID=123,CategoryName = "Roomba"});

    var repository = new Mock<NorthwindRepository>();

    repository.Expect(r => r.Categories).Returns(categories.AsQueryable());

    var controller = new ProductsController(repository.Object);

    var result = controller.Category(123) as ViewResult;

    Assert.IsNotNull(result, "Expected the result to be a render view result");

    Assert.AreEqual("Roomba", result.ViewData["CategoryName"]);

    var viewData = result.ViewData.Model as Category ;

    Assert.AreEqual(123, viewData.CategoryID);

    Assert.AreEqual("Roomba", viewData.CategoryName);

    }

    First, you should have noticed here that we have not only referred to the built-in namespace Microsoft.VisualStudio.TestTools.UnitTesting, but also to Moq. The current version of Moq is 2.5.3. Although this framework is simple, due to introducing the new lambda expression, Moq can provide a clear grammar form to describe the expectation, parameter constrains, and returned values. For detailed information, you can refer to this blog .

    In the unit test programming, when complex objects are used (in this case the NorthwindRepository typed variable) or difficult to implement for the time being, we can rest on the Mock object to simulate the target object, which is properly consistent with the basic idea of TDD. Here, we will use the Moq class provided by the Moq framework to mock the NorthwindRepository class, as follows:

    var repository = new Mock<NorthwindRepository>();

    Next, we use the following sentence to set up the expectation of the set of the Category objects:

    repository.Expect(r => r.Categories).Returns(categories.AsQueryable());

    Then, we create an instance of the ProductsController class and pass in the repository.Object. Note here that the repository represents the mock object, while the repository.Object refers to the target object that the mock object mocks.

    Since the last several Asserts are easy to follow, we won't dwell on them.

    Well, how are you feeling now? It’s not as easy as you imagine if you do not possess the abundant and solid basic TDD knowledge and all the other required programming skills, isn’t it? In fact, there are many more parts that need to be tested: the Route, the ViewData, the HTTPContext-related items, etc.

    Another fact is that for now the MVC framework has not even published its normal release version, and therefore, no detailed help documents can be found (so most of the reference material can only be hunted down from blogs).

    Anyway, the ASP.NET MVC is a new and alternate architecture for your ASP.NET applications, with many new features completed and many more to be added.

    More ASP.NET Articles
    More By Xianzhong Zhu


       · I would like to point out that unit testing is not a requirement of an MVC project....
       · I rated "Disadvantages of the ASP.NET MVC Framework" 4/5 even though I'm a tough...
       · There is no replacement for proper planning and a good design. The first best...
       · MVC is a major boon for my company. We spend on average half the amount of time on...
     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek