Hi,
I try to use the mocking framework with visual basic and I try to figure it out what is the best manner to fake a method.
When I try to fake a function, the syntaxe is very nice like this:
<Test()> _
Public Sub TestDelete()
Dim fileManager As JustMockFile.IFileManager
fileManager = Mock.Create(Of JustMockFile.IFileManager)()
Mock.Arrange(Function() fileManager.Delete(Arg.AnyString)).Returns(False)
Assert.IsTrue(fileManager.Delete(""))
End Sub
As you can see, the keyword "Function()" is use and when I call the "Delete" function of the FileManager, I have a full support with intellisense to define possibles values of each arguments.
The problem is when I try to fake a method because I don't know how to call Arrange correctly except with the keyword "AddressOf". The problem with "AddressOf" is that I don't have a full support with intellisense and i'm limited with 9 parameters.
<Test()> _
Public Sub TestCreate()
Dim fileManager As JustMockFile.IFileManager
fileManager = Mock.Create(Of JustMockFile.IFileManager)()
Mock.Arrange(AddressOf fileManager.Create, Arg.AnyString)
Mock.Assert(AddressOf fileManager.Create, Arg.AnyString, Occurs.Once)
End Sub
I have full of legacy applications where many methods have more then 9 parameters. Any ways, I don't have full support with Intellisense.
I want to be able to fake a method like this:
<Test()> _
Public Sub TestCreate()
Dim fileManager As JustMockFile.IFileManager
fileManager = Mock.Create(Of JustMockFile.IFileManager)()
Mock.Arrange(function() fileManager.Create(Arg.AnyString))
Mock.Assert(function() fileManager.Create(Arg.AnyString) Occurs.Once)
End Sub
Is there any way to fake method like a function with Visual Basic... with the "Function()" keyword?
Thank you very much
I try to use the mocking framework with visual basic and I try to figure it out what is the best manner to fake a method.
When I try to fake a function, the syntaxe is very nice like this:
<Test()> _
Public Sub TestDelete()
Dim fileManager As JustMockFile.IFileManager
fileManager = Mock.Create(Of JustMockFile.IFileManager)()
Mock.Arrange(Function() fileManager.Delete(Arg.AnyString)).Returns(False)
Assert.IsTrue(fileManager.Delete(""))
End Sub
As you can see, the keyword "Function()" is use and when I call the "Delete" function of the FileManager, I have a full support with intellisense to define possibles values of each arguments.
The problem is when I try to fake a method because I don't know how to call Arrange correctly except with the keyword "AddressOf". The problem with "AddressOf" is that I don't have a full support with intellisense and i'm limited with 9 parameters.
<Test()> _
Public Sub TestCreate()
Dim fileManager As JustMockFile.IFileManager
fileManager = Mock.Create(Of JustMockFile.IFileManager)()
Mock.Arrange(AddressOf fileManager.Create, Arg.AnyString)
Mock.Assert(AddressOf fileManager.Create, Arg.AnyString, Occurs.Once)
End Sub
I have full of legacy applications where many methods have more then 9 parameters. Any ways, I don't have full support with Intellisense.
I want to be able to fake a method like this:
<Test()> _
Public Sub TestCreate()
Dim fileManager As JustMockFile.IFileManager
fileManager = Mock.Create(Of JustMockFile.IFileManager)()
Mock.Arrange(function() fileManager.Create(Arg.AnyString))
Mock.Assert(function() fileManager.Create(Arg.AnyString) Occurs.Once)
End Sub
Is there any way to fake method like a function with Visual Basic... with the "Function()" keyword?
Thank you very much