Skip to content

Commit e7fec19

Browse files
committed
Testing the same methods/properties are not diagnosed on other classes
1 parent 1893a93 commit e7fec19

3 files changed

Lines changed: 100 additions & 0 deletions

File tree

src/NServiceBus.AzureFunctions.Analyzer.Tests/AzureFunctionsConfigurationAnalyzerTests.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace NServiceBus.AzureFunctions.Analyzer.Tests
22
{
3+
using System.Threading;
4+
using System;
35
using System.Threading.Tasks;
46
using NUnit.Framework;
57
using static AzureFunctionsDiagnostics;
@@ -33,5 +35,42 @@ void Bar(ServiceBusTriggeredEndpointConfiguration endpointConfig)
3335

3436
return Assert(diagnosticId, source);
3537
}
38+
39+
[TestCase("DefineCriticalErrorAction((errorContext, cancellationToken) => Task.CompletedTask)", DefineCriticalErrorActionNotAllowedId)]
40+
[TestCase("LimitMessageProcessingConcurrencyTo(5)", LimitMessageProcessingToNotAllowedId)]
41+
[TestCase("MakeInstanceUniquelyAddressable(null)", MakeInstanceUniquelyAddressableNotAllowedId)]
42+
[TestCase("OverrideLocalAddress(null)", OverrideLocalAddressNotAllowedId)]
43+
[TestCase("PurgeOnStartup(true)", PurgeOnStartupNotAllowedId)]
44+
[TestCase("SetDiagnosticsPath(null)", SetDiagnosticsPathNotAllowedId)]
45+
[TestCase("UseTransport(new AzureServiceBusTransport(null))", UseTransportNotAllowedId)]
46+
public Task DiagnosticIsNotReportedForOtherEndpointConfiguration(string configuration, string diagnosticId)
47+
{
48+
var source =
49+
$@"using NServiceBus;
50+
using System;
51+
using System.Threading;
52+
using System.Threading.Tasks;
53+
54+
class SomeOtherClass
55+
{{
56+
internal void DefineCriticalErrorAction(Func<ICriticalErrorContext, CancellationToken, Task> onCriticalError) {{ }}
57+
internal void LimitMessageProcessingConcurrencyTo(int Number) {{ }}
58+
internal void MakeInstanceUniquelyAddressable(string someProperty) {{ }}
59+
internal void OverrideLocalAddress(string someProperty) {{ }}
60+
internal void PurgeOnStartup(bool purge) {{ }}
61+
internal void SetDiagnosticsPath(string someProperty) {{ }}
62+
internal void UseTransport(AzureServiceBusTransport transport) {{ }}
63+
}}
64+
65+
class Foo
66+
{{
67+
void Bar(SomeOtherClass endpointConfig)
68+
{{
69+
endpointConfig.{configuration};
70+
}}
71+
}}";
72+
73+
return Assert(diagnosticId, source);
74+
}
3675
}
3776
}

src/NServiceBus.AzureFunctions.Analyzer.Tests/AzureFunctionsSendReplyOptionsAnalyzerTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,34 @@ void Bar({optionsType} options)
2626

2727
return Assert(diagnosticId, source);
2828
}
29+
30+
31+
[TestCase("SomeOtherClass", "RouteReplyToAnyInstance", RouteReplyToAnyInstanceNotAllowedId)]
32+
[TestCase("SomeOtherClass", "RouteReplyToThisInstance", RouteReplyToThisInstanceNotAllowedId)]
33+
[TestCase("SomeOtherClass", "RouteToThisInstance", RouteToThisInstanceNotAllowedId)]
34+
public Task DiagnosticIsNotReportedForOtherOptions(string optionsType, string method, string diagnosticId)
35+
{
36+
var source =
37+
$@"using NServiceBus;
38+
using System;
39+
using System.Threading.Tasks;
40+
41+
class SomeOtherClass
42+
{{
43+
internal void RouteReplyToAnyInstance() {{ }}
44+
internal void RouteReplyToThisInstance() {{ }}
45+
internal void RouteToThisInstance() {{ }}
46+
}}
47+
48+
class Foo
49+
{{
50+
void Bar({optionsType} options)
51+
{{
52+
options.{method}();
53+
}}
54+
}}";
55+
56+
return Assert(diagnosticId, source);
57+
}
2958
}
3059
}

src/NServiceBus.AzureFunctions.Analyzer.Tests/AzureFunctionsTransportAnalyzerTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,37 @@ void Extension(TransportExtensions<AzureServiceBusTransport> transportExtension)
3636

3737
return Assert(diagnosticId, source);
3838
}
39+
40+
[TestCase("EntityMaximumSize", "5", EntityMaximumSizeNotAllowedId)]
41+
[TestCase("MaxAutoLockRenewalDuration", "new System.TimeSpan(0, 0, 5, 0)", MaxAutoLockRenewalDurationNotAllowedId)]
42+
[TestCase("PrefetchCount", "5", PrefetchCountNotAllowedId)]
43+
[TestCase("PrefetchMultiplier", "5", PrefetchMultiplierNotAllowedId)]
44+
[TestCase("TimeToWaitBeforeTriggeringCircuitBreaker", "new System.TimeSpan(0, 0, 5, 0)", TimeToWaitBeforeTriggeringCircuitBreakerNotAllowedId)]
45+
public Task DiagnosticIsNotReportedForNonTransportConfiguration(string configName, string configValue, string diagnosticId)
46+
{
47+
var source =
48+
$@"using NServiceBus;
49+
using System;
50+
using System.Threading.Tasks;
51+
52+
class SomeOtherClass
53+
{{
54+
internal int EntityMaximumSize {{ get; set; }}
55+
internal TimeSpan MaxAutoLockRenewalDuration {{ get; set; }}
56+
internal int PrefetchCount {{ get; set; }}
57+
internal int PrefetchMultiplier {{ get; set; }}
58+
internal TimeSpan TimeToWaitBeforeTriggeringCircuitBreaker {{ get; set; }}
59+
}}
60+
61+
class Foo
62+
{{
63+
void Direct(SomeOtherClass endpointConfig)
64+
{{
65+
endpointConfig.{configName} = {configValue};
66+
}}
67+
}}";
68+
69+
return Assert(diagnosticId, source);
70+
}
3971
}
4072
}

0 commit comments

Comments
 (0)