I'm new to unit testing practices, the problem I have is in the code below, the method TestEnums
it seems to stop/break the iteration when the first Assert fail, I mean, it only shows one failed error message in the Test Explorer.
I would like to adapt this code to show all the failed asserts in the Test Explorer, that is, every tested Enum that failed the assert of EnumHasRepeatedValues
method.
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports System.Reflection
<TestClass()>
Public Class Application
<TestMethod()>
Public Sub TestEnums()
Dim ass As Assembly = Assembly.Load("Elektro.Application")
Dim types As IEnumerable(Of Type) =
From t As Type In ass.GetTypes() Where t.IsEnum
For Each t As Type In types
EnumHasRepeatedValues(t)
Next
End Sub
Public Sub EnumHasRepeatedValues(ByVal t As Type)
Assert.AreEqual([Enum].GetValues(t).Length,
[Enum].GetNames(t).Length,
String.Format("Enum {0}.{1} has defined repeated values.",
t.Namespace, t.Name))
End Sub
End Class