下面代码中的 assert 语句不能正常工作。如何通过另一个变量决策来控制断言?我是编码新手。
<TestClass>
Public Class FactorsOf32DictionaryCatchError
<TestMethod>
Sub TestSub()
Dim FactorsOf32 As New Dictionary(Of Integer, Integer)
FactorsOf32.Add(1, 32)
FactorsOf32.Add(2, 16)
FactorsOf32.Add(4, 8)
FactorsOf32.Add(32, 1)
FactorsOf32.Add(16, 2)
FactorsOf32.Add(8, 4)
Dim ProductOf32 As Integer
Dim i As Integer = 0
For i = 1 To 32
Try
ProductOf32 = FactorsOf32.Item(i) * i
Catch
Debug.Print(String.Format("Error is contained in the operation"))
End Try
Assert.AreEqual(ProductOf32, 32, "The result did not contain what you thought")
Next i
End Sub
End Class
End Namespace