-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathConfigurationAnalyzerTests.cs
More file actions
73 lines (65 loc) · 3.04 KB
/
ConfigurationAnalyzerTests.cs
File metadata and controls
73 lines (65 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
namespace NServiceBus.AzureFunctions.InProcess.Analyzer.Tests;
using System.Threading.Tasks;
using NUnit.Framework;
using static AzureFunctionsDiagnostics;
[TestFixture]
public class ConfigurationAnalyzerTests : AnalyzerTestFixture<ConfigurationAnalyzer>
{
[TestCase("DefineCriticalErrorAction((errorContext, cancellationToken) => Task.CompletedTask)", DefineCriticalErrorActionNotAllowedId)]
[TestCase("LimitMessageProcessingConcurrencyTo(5)", LimitMessageProcessingToNotAllowedId)]
[TestCase("MakeInstanceUniquelyAddressable(null)", MakeInstanceUniquelyAddressableNotAllowedId)]
[TestCase("OverrideLocalAddress(null)", OverrideLocalAddressNotAllowedId)]
[TestCase("PurgeOnStartup(true)", PurgeOnStartupNotAllowedId)]
[TestCase("SetDiagnosticsPath(null)", SetDiagnosticsPathNotAllowedId)]
[TestCase("UseTransport(new AzureServiceBusTransport(null, default(TopicTopology)))", UseTransportNotAllowedId)]
public Task DiagnosticIsReportedForEndpointConfiguration(string configuration, string diagnosticId)
{
var source =
$@"using NServiceBus;
using System;
using System.Threading.Tasks;
class Foo
{{
void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
{{
[|endpointConfig.AdvancedConfiguration.{configuration}|];
var advancedConfig = endpointConfig.AdvancedConfiguration;
[|advancedConfig.{configuration}|];
}}
}}";
return Assert(diagnosticId, source);
}
[TestCase("DefineCriticalErrorAction((errorContext, cancellationToken) => Task.CompletedTask)", DefineCriticalErrorActionNotAllowedId)]
[TestCase("LimitMessageProcessingConcurrencyTo(5)", LimitMessageProcessingToNotAllowedId)]
[TestCase("MakeInstanceUniquelyAddressable(null)", MakeInstanceUniquelyAddressableNotAllowedId)]
[TestCase("OverrideLocalAddress(null)", OverrideLocalAddressNotAllowedId)]
[TestCase("PurgeOnStartup(true)", PurgeOnStartupNotAllowedId)]
[TestCase("SetDiagnosticsPath(null)", SetDiagnosticsPathNotAllowedId)]
[TestCase("UseTransport(new AzureServiceBusTransport(null, default(TopicTopology)))", UseTransportNotAllowedId)]
public Task DiagnosticIsNotReportedForOtherEndpointConfiguration(string configuration, string diagnosticId)
{
var source =
$@"using NServiceBus;
using System;
using System.Threading;
using System.Threading.Tasks;
class SomeOtherClass
{{
internal void DefineCriticalErrorAction(Func<ICriticalErrorContext, CancellationToken, Task> onCriticalError) {{ }}
internal void LimitMessageProcessingConcurrencyTo(int Number) {{ }}
internal void MakeInstanceUniquelyAddressable(string someProperty) {{ }}
internal void OverrideLocalAddress(string someProperty) {{ }}
internal void PurgeOnStartup(bool purge) {{ }}
internal void SetDiagnosticsPath(string someProperty) {{ }}
internal void UseTransport(AzureServiceBusTransport transport) {{ }}
}}
class Foo
{{
void Bar(SomeOtherClass endpointConfig)
{{
endpointConfig.{configuration};
}}
}}";
return Assert(diagnosticId, source);
}
}