Книга: C# 2008 Programmer

Adding Additional Test Methods

Adding Additional Test Methods

You can insert additional test methods by adding new subroutines to the PointTest.cs file and prefixing them with the [TestMethod] attribute. For example, the following test method uses the AreSame() method of the Assert class to check whether two objects are pointing to the same reference:

[TestMethod()]
public void objectTest() {
 Point point1 = new Point(4, 5);
 Point point2 = new Point() { x = 4, y = 5 };
 Point point3 = point2;
 //---Failed---
 Assert.AreSame(point1, point2, "point1 is not the same as point2";
 //---Passed---
 Assert.AreSame(point2, point3, "point2 is not the same as point3";
}

Figure 2-77 shows the test results.


Figure 2-77 

Оглавление книги


Генерация: 1.748. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз