## Utility Methods

Four utility methods, Pass(), Fail(), Ignore() and Inconclusive() are provided in order to allow more direct control of the test process:

    Assert.Pass();
    Assert.Pass( string message );
    Assert.Pass( string message, object[] parms );

    Assert.Fail();
    Assert.Fail( string message );
    Assert.Fail( string message, object[] parms );

    Assert.Ignore();
    Assert.Ignore( string message );
    Assert.Ignore( string message, object[] parms );

    Assert.Inconclusive();
    Assert.Inconclusive( string message );
    Assert.Inconclusive( string message, object[] parms );

The Assert.Pass method allows you to immediately end the test, recording it as successful. Since it causes an exception to be thrown, it is more efficient to simply allow the test to return. However, Assert.Pass allows you to record a message in the test result and may also make the test easier to read in some situations. Additionally, like the other methods on this page, it can be invoked from a nested method call with the result of immediately terminating test execution.

The Assert.Fail method provides you with the ability to generate a failure based on tests that are not encapsulated by the other methods. It is also useful in developing your own project-specific assertions.

Here's an example of its use to create a private assertion that tests whether a string contains an expected value.

    public void AssertStringContains( string expected, string actual )
    {
        AssertStringContains( expected, actual, string.Empty );
    }

    public void AssertStringContains( string expected, string actual,
        string message )
    {
        if ( actual.IndexOf( expected ) < 0 )
            Assert.Fail( message );
    }

The Assert.Ignore method provides you with the ability to dynamically cause a test or suite to be ignored at runtime. It may be called in a test, setup or fixture setup method. We recommend that you use this only in isolated cases. The category facility is provided for more extensive inclusion or exclusion of tests or you may elect to simply divide tests run on different occasions into different assemblies.

The Assert.Inconclusive method indicates that the test could not be completed with the data available. It should be used in situations where another run with different data might run to completion, with either a success or failure outcome.