开发者

MVC Unit Testing [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

can anyone explain me the real concept of doing unit testing for model classes.

public class category
{
    public int ID;
    public string Name;
}

In my test class, i saw people writing code like this

[TestClass]
public class CategoryTest
{
    [TestMethod]
    public void Category_Test()
    {
        //Arrange
        category = new Category() { intialisation};
  开发者_JAVA百科      //Act

        //Assert
        check again you have same values are not;
    }
}

I couldn't see any value of testing model classes testing without interacting to databases?


Unit Testing - Wiki

Unit testing is a method by which individual units of source code are tested to determine if they are fit for use. A unit is the smallest testable part of an application. In procedural programming a unit may be an individual function or procedure. In object-oriented programming a unit is usually a method. Unit tests are created by programmers or occasionally by white box testers during the development process.

Unit tests will not use actual objects; it will be performed using Mock objects.


@Anuraj is right, a great example project for all things MVC is Nerd Dinner http://nerddinner.codeplex.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜