Simple Moq ? - Problem with .Verify

Posted by user127954 on Stack Overflow See other posts from Stack Overflow or by user127954
Published on 2010-04-27T17:56:35Z Indexed on 2010/04/27 18:03 UTC
Read the original article Hit count: 292

Filed under:

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)
        mock.Object.WriteError("test", "Test")
        .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.

© Stack Overflow or respective owner

Related posts about moq