V3 Documentation
Search

NCrunch.Framework.NCrunchEnvironment class

NCrunch.Framework Class

When you are making use of the NCrunch.Framework assembly, you are able to make use of NCrunch's runtime features. All runtime features are currently attached to the NCrunch.Framework.NCrunchEnvironment class.

The NCrunchEnvironment class contains methods that allow you to query additional information about the context in which NCrunch is executing your tests. The following methods exist:

NCrunchIsResident()

public static bool NCrunchIsResident()

This method will return true if NCrunch is responsible for the execution of your test, or false if your test is being executed by another test runner. You can use this method to implement alternative logic in your test that may be suitable only for a continuous test runner.

Data supplied by this method is sourced from the NCrunch environment variable.

GetOriginalSolutionPath()

public static string GetOriginalSolutionPath()

This method will return the full file path of the .sln file for the solution currently open in Visual Studio. Note that this is the solution you are currently working with in the IDE, not a virtual solution created within an NCrunch workspace. This method is extremely useful for situations where you need to reference files on a relative path from the solution file where those files have not been included in the NCrunch workspace.

Data supplied by this method is sourced from the NCrunch.OriginalSolutionPath environment variable.

When executing on a grid node, this method will return the path of the solution file as it would exist within the stored solution snapshot on the node.

GetOriginalProjectPath()

public static string GetOriginalProjectPath()

This method will return the full file path of the .proj file for the applicable project currently open in Visual Studio. As with the GetOriginalSolutionPath() method, the path returned is that of the original project file as it is open within Visual Studio, not any temporary project files artificially constructed in NCrunch workspaces.

Data supplied by this method is sourced from the NCrunch.OriginalProjectPath environment variable.

When executing on a grid node, this method will return the path of the project file as it would exist within the stored solution snapshot on the node.

GetImplicitlyReferencedAssemblyLocations()

public static string[] GetImplicitlyReferencedAssemblyLocations()

This method returns an array of the full file paths of each of the assemblies implicitly referenced in the current domain through the use of the implicit project dependencies configuration setting.

Data supplied by this method is sourced from the NCrunch.ImplicitlyReferencedAssemblyLocations environment variable.

GetAllAssemblyLocations()

public static string[] GetAllAssemblyLocations()

This method returns an array of the full file paths of every assembly expected to be used in the current domain, including implicitly referenced assemblies using the implicit project dependencies configuration setting. Because this method returns assemblies that may not have yet been loaded into the current application domain, it can be a much more useful alternative to AppDomain.CurrentDomain.GetAssemblies().

Data supplied by this method is sourced from the NCrunch.AllAssemblyLocations environment variable.