MVC Unit Testing [closed]
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/
精彩评论