Hi, just a simple question here. I've used Moq for awhile but, as of yet, have only used it for stubbing and not for mocking. I am trying to introduce our developers to unit testing. I set up a simple example to explain the concepts but i can't seem to get it working. Probably something simple so i thought i would just ask you all to see what i'm doing wrong:
<Test()> _
Public Sub Divide_DivideByZero_LogsError()
Dim mock = New Mock(Of ILogger)
With mock
Dim calc = New MyCalculator(New CalculatorData, .Object)
calc.Divide(55, 0)
.Verify(Function(x) CType(x,ILogger).WriteError(it.IsAny(of String),It.IsAny(Of String))))
End With
End Sub
I'm using Moq version 3.2.416.3. I get an error on the .verify telling me that i'm calling it with incorrect arguments. I'm just trying to verify that .WriteError was called. any help would be appreciated.
Edit: Ok everyone, if i change ".WriteError" from a sub (void return) to a function that returns a boolean it works. WriteError doesn't really need to be a function. Does anyone know why a sub wouldn't work?