Hi I have this situation.
I would like to Mock my private function GetSomeQuantity.
It is private. When it is public it would work by doing this:
But how can I do this for a private function?
I did try it using the nonpublic, but it keeps giving me an error that it cannot resolve the method and that I should check my arguments.
Any help would be appreciated.
Thanks,
Wietze
Public
Class
PrivateMethodDoInstead
Private
Function
GetSomeQuantity(
ByRef
quantity
As
Long
)
As
Boolean
'....get quantity from the database code would be here
Return
quantity > 0
End
Function
Public
Function
HandleRecords()
As
Boolean
Dim
quantity
As
Long
Dim
returnValue
As
Boolean
= GetSomeQuantity(quantity)
If
returnValue
Then
StoreTotals(quantity)
End
If
Return
returnValue
End
Function
Private
Sub
StoreTotals(quantity
As
Long
)
' do something
End
Sub
End
Class
I would like to Mock my private function GetSomeQuantity.
It is private. When it is public it would work by doing this:
Mock.Arrange(
Function
() testInstance.GetSomeQuantity(
Arg.IsAny(Of
Long
))
).DoInstead(
Function
(
ByRef
quantity
As
Long
)
As
Boolean
quantity = 5
Return
True
End
Function
).Returns(
True
)
But how can I do this for a private function?
I did try it using the nonpublic, but it keeps giving me an error that it cannot resolve the method and that I should check my arguments.
Any help would be appreciated.
Thanks,
Wietze