MVC Unit Testing
http://www.codeproject.com/Articles/763928/MVC-Unit-Testing-Unleashed
Basic example of Unit Testing
Step 1. Create a class library which need to be tested with following code block.
public class CustomMaths { public int Add(int num1,int num2) { return Number1 + Number2; } }
Step 2. Create Unit Testing Project as Follows
Step 3. Add reference of previous class library to this newly created project
Step 4. Create Test class as follows
[TestClass] public class TestMathsClass { [TestMethod] public void TestAdd() { //Arrange CustomMaths maths = new CustomMaths(6, 5); //Act int result = maths.Add(); //Assert Assert.AreEqual<int>(11, result); } }
Comments
Post a Comment