MetalamaAPI documentationAdvanced APIMetalama.​Testing.​Aspect­TestingTest­Scenario
Open sandboxFocus

TestScenario Class

Enumerates the scenarios that are simulated for the test, for instance compilation (the Default scenario), applying a code fix, or others.

Inheritance
System.Object
TestScenario
Namespace: Metalama.Testing.AspectTesting
Assembly: Metalama.Testing.AspectTesting.dll
Syntax
public sealed class TestScenario : Enum

Fields

Name Description
ApplyCodeFix

This value indicates that a code fix should be applied. When this value is set, the output buffer of the test is not the one transformed by the aspect, but the one transformed by the code fix. The test will fail if it does not generate any diagnostic with a code fix. By default, the first emitted code fix is applied. To apply a different code fix, use the AppliedCodeFixIndex property. To set this scenario in a test, add this comment to your test file: // @TestScenario(ApplyCodeFix).

ApplyLiveTemplate

This value indicates that a live template should be applied. To enable this option in a test, add this comment to your test file: // @TestScenario(ApplyLiveTemplate).

Default

The default test scenario is that the code is transformed as during compilation.

PreviewCodeFix

This value indicates that a code fix preview should be applied. When this value is set, the output buffer of the test is not the one transformed by the aspect, but the one transformed by the code fix. The test will fail if it does not generate any diagnostic with a code fix. By default, the first emitted code fix is applied. To apply a different code fix, use the AppliedCodeFixIndex property. To enable this option in a test, add this comment to your test file: // @TestScenario(PreviewCodeFix).

PreviewLiveTemplate

This value indicates that a live template preview should be applied. To enable this option in a test, add this comment to your test file: // @TestScenario(PreviewLiveTemplate).

value__