The Assert Classes
The UnitTesting
namespace also includes the Assert
static type. This object contains methods for evaluating whether the results of a test were as expected. You call these static methods and expect a true/false
condition. If the Boolean condition fails, the assertion fails. The assertions do not actually return results. Rather, they automatically notify the unit test framework at runtime if the assertion fails or succeeds.
As an example, you might write a unit test to load a known record from the database. You would then write assertions about this known record to prove that you can retrieve the data from the database and properly call the right set
s and get
s on a specific object. The following shows a simple assertion for testing ...
Get Microsoft Visual Studio 2015 Unleashed, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.