2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-08-13 16:51:27 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Noncompliant code example
|
2021-08-13 16:51:27 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,vbnet]
|
2021-08-13 16:51:27 +02:00
|
|
|
----
|
|
|
|
<TestMethod>
|
|
|
|
<ExpectedException(GetType(ArgumentNullException))> ' Noncompliant
|
|
|
|
Public Sub TestNullArg()
|
|
|
|
'...
|
|
|
|
End Sub
|
|
|
|
----
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2021-08-13 16:51:27 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,vbnet]
|
2021-08-13 16:51:27 +02:00
|
|
|
----
|
|
|
|
<TestMethod>
|
|
|
|
Public Sub TestNullArg()
|
|
|
|
Dim CallFailed As Boolean = False
|
|
|
|
Try
|
|
|
|
' ...
|
|
|
|
Catch ex As Exception
|
|
|
|
CallFailed = true
|
|
|
|
End Try
|
|
|
|
Assert.IsTrue(CallFailed, "Expected call to MyMethod to fail with ArgumentNullException")
|
|
|
|
End Sub
|
|
|
|
----
|
|
|
|
|
|
|
|
or
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,vbnet]
|
2021-08-13 16:51:27 +02:00
|
|
|
----
|
|
|
|
<TestMethod>
|
|
|
|
Public Sub TestNullArg()
|
|
|
|
Assert.ThrowsException(Of ArgumentNullException)(Sub() ... )
|
|
|
|
End Sub
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../exceptions.adoc[]
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
2021-09-21 11:30:38 +02:00
|
|
|
include::../comments-and-links.adoc[]
|
2021-08-13 16:51:27 +02:00
|
|
|
endif::env-github,rspecator-view[]
|