public void AnalyzeWhenAssemblyAttributeIsNotParallelScopeSelf(ParallelScope parallelScope) { var enumValue = parallelScope.ToString(); var testCode = $@" using NUnit.Framework; [assembly: Parallelizable(ParallelScope.{enumValue})]"; AnalyzerAssert.Valid <ParallelizableUsageAnalyzer>(testCode); }
public void AnalyzeWhenAttributeIsOnClass(ParallelScope parallelScope) { var enumValue = parallelScope.ToString(); var testCode = TestUtility.WrapClassInNamespaceAndAddUsing($@" [TestFixture] [Parallelizable(ParallelScope.{enumValue})] public sealed class AnalyzeWhenAttributeIsOnClass {{ }}"); AnalyzerAssert.Valid <ParallelizableUsageAnalyzer>(testCode); }
public void AnalyzeWhenAttributeIsOnParametricTestMethodNotParallelScopeFixtures(ParallelScope parallelScope) { var enumValue = parallelScope.ToString(); var testCode = TestUtility.WrapClassInNamespaceAndAddUsing($@" [TestFixture] public sealed class AnalyzeWhenAttributeIsOnParametricTestMethodNotParallelScopeFixtures {{ [Test] [Parallelizable(ParallelScope.{enumValue})] public void Test([Values(1, 2, 3)] int data) {{ }} }}"); AnalyzerAssert.Valid <ParallelizableUsageAnalyzer>(testCode); }
public void AnalyzeWhenAttributeIsOnTestCaseTestMethodNotParallelScopeFixtures(ParallelScope parallelScope) { var enumValue = parallelScope.ToString(); var testCode = TestUtility.WrapClassInNamespaceAndAddUsing($@" [TestFixture] public sealed class AnalyzeWhenAttributeIsOnTestCaseTestMethodNotParallelScopeFixtures {{ [TestCase(1)] [Parallelizable(ParallelScope.{enumValue})] public void Test(int data) {{ }} }}"); RoslynAssert.Valid(this.analyzer, testCode); }
public void AnalyzeWhenAttributeIsOnSimpleTestMethodContainsParallelScopeChildren(ParallelScope parallelScope) { var expectedDiagnostic = ExpectedDiagnostic.Create( AnalyzerIdentifiers.ParallelScopeChildrenOnNonParameterizedTestMethodUsage, ParallelizableUsageAnalyzerConstants.ParallelScopeChildrenOnNonParameterizedTestMethodMessage); var enumValue = parallelScope.ToString(); var testCode = TestUtility.WrapClassInNamespaceAndAddUsing($@" [TestFixture] public sealed class AnalyzeWhenAttributeIsOnSimpleTestMethodContainsParallelScopeChildren {{ [Test] [↓Parallelizable(ParallelScope.{enumValue})] public void Test() {{ }} }}"); AnalyzerAssert.Diagnostics(analyzer, expectedDiagnostic, testCode); }