Unit Test path C # edition (1)

Source: Internet
Author: User

Various Nunit assertions
First, assertions are some functions that can be used to test whether the tested functions work normally.
The Nunit library is provided to Testers in the form of static Assert methods.
AreEqual (expected, actual [, string message])
Parameter description: The first parameter is the expected value, the second parameter is the actual value generated by the test code, and the third parameter is the message reported when an error occurs.
Functional constraints: Any object can be used for Equality testing. However, if you want to use this assertion to compare floating point numbers, you need to specify an additional error parameter. This is because the computer cannot accurately represent all floating point numbers.
IsNull (objec [, string message])/IsNotNull (object [, string message])
Parameter description: The first parameter is the object to be verified, and the second parameter is the same as above.
Functional constraints: verify whether a given object is null or not null.
AreSame (expected, actual [, string message])
Parameter description: the first is the expected object, and the second is the actual object.
Function constraint: verify whether the two parameters reference the same object.
IsTrue (bool condition [, string message])/IsFalse (bool condition [, string message])
Parameter description: The first parameter is a binary condition to be verified.
Functional constraints: whether the verification conditions are true or false.
Fail ([string message])
Function constraint: make the current test fail immediately. This type of assertion is usually used to mark a branch that should not be reached, but it is not commonly used in practice.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.