#副標=軟體團隊開發工具VSTS (3)
#大標=VSTS應用在軟體測試
#眉標=Visutal Studio Team System
#作者=文/歐宣修
=========box程式1=========
Computation.cs
public class Computation
{
public static int Compute(ComputeMethod
method, int firstNumber, int secondNumber)
{
if (method == ComputeMethod.Add)
return firstNumber + secondNumber;
else if (method == ComputeMethod.Subtract)
return firstNumber - secondNumber;
else if (method == ComputeMethod.Multiply)
return firstNumber * secondNumber;
else if (method == ComputeMethod.Divide)
return firstNumber / secondNumber;
else
throw new ApplicationException("This
operation is not supported!");
}
}
public enum ComputeMethod
{
Add,
Subtract,
Multiply,
Divide
}
==========end===========
========box程式2========
ComputationTest.cs
[TestClass()]
public class ComputationTest
{
private TestContext testContextInstance;
///
///Gets or sets the test context which provides
///information about and functionality for the current
test run.
///
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
///
///A test for Compute (ComputeMethod, int, int)
///
[TestMethod()]
public void ComputeAddTest()
{
ComputeMethod method = ComputeMethod.Add;
int firstNumber = 4;
int secondNumber = 5;
int expected = 9;
int actual;
actual = ClassLibrary1.Computation.Compute(
method, firstNumber, secondNumber);
Assert.AreEqual(expected, actual, "ClassLibrary1.
Computation.Compute did not return the expected
value.");
}
///
///A test for Compute (ComputeMethod, int, int)
///
[TestMethod()]
public void ComputeSubtractTest()
{
ComputeMethod method = ComputeMethod.
Subtract;
int firstNumber = 5;
int secondNumber = 4;
int expected = 1;
int actual;
actual = ClassLibrary1.Computation.Compute(
method, firstNumber, secondNumber);
Assert.AreEqual(expected, actual, "ClassLibrary1.
Computation.Compute did not return the expected
value.");
}
}
============end============
=========box TFSBuild.proj檔=======
TFSBuild.proj
略…
vsap
SenshawTestAgile
C:\Build
\\vsap\Drop
true
略…
略…
Computation
略…
==============end=============