Open sandboxFocus

Class UnitTestClass

A base class for all Metalama unit tests that require Metalama services. Exposes a CreateTestContext(IAdditionalServiceCollection) that creates a context with all services. The next step is typically to call one of the methods or properties of the returned TestContext.

Inheritance
UnitTestClass
Namespace: Metalama.Testing.UnitTesting
Assembly: Metalama.Testing.UnitTesting.dll
Syntax
public abstract class UnitTestClass

Constructors

Name Description
UnitTestClass(ITestOutputHelper?, bool)

Initializes a new instance of the UnitTestClass class.

Properties

Name Description
TestOutput

Gets an object allowing to write to the test output.

Methods

Name Description
AddSyntaxGenerationOptions(IAdditionalServiceCollection)
ConfigureServices(IAdditionalServiceCollection)

Adds services or mocks that are common to all tests in the current class. This method is called by CreateTestContext(IAdditionalServiceCollection) and the services parameter is the one passed to the CreateTestContext(IAdditionalServiceCollection), if any, or an empty collection otherwise.

CreateAdditionalServiceCollection(params IService[])

Creates a collection of additional services that can then be passed to CreateTestContext(IAdditionalServiceCollection).

CreateTestContext()
CreateTestContext(IAdditionalServiceCollection)

Creates a test context with a collection of additional services or mocks.

CreateTestContext(TestContextOptions?, IAdditionalServiceCollection?)

Creates a test context, optionally with a non-default TestContextOptions or a collection of additional services or mocks.

CreateTestContextCore(TestContextOptions, IAdditionalServiceCollection)
GetDefaultTestContextOptions()