chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I've been trying out some test mockings with TypeMock and they seem to work well except for one test case that I encountered.

I have a class under test

Public Class ClassUnderTest
public function PostPurchaseOrder() As SalesOrderPostingOutput

Dim userid as string
Dim logon As New Encore.Utilities
userid = logon.Logon("username", "password", "T", "", encore.Language.ENGLISH, 0, 0, "")

return nothing ' just for testing
end Function

end Class

<NUnit.Framework.Test()> _
Public Sub TestPostPurchaseOrder()
Dim EncoreUtilities As Mock = MockManager.Mock(GetType(Encore.Utilities))
EncoreUtilities.AlwaysReturn("Logon", "Test Data")
Dim syspro As New ClassUnderTest
end Sub

When I run the above test, error message "Cannot type mock Interfaces or Abstract classes use MockObject" appears. So I change the Mock to MockObject. The problem is now is that the logon.Logon is never mocked. Instead, the original logon.Logon is called. Could it be that Encore.Utilities is not native dotnet but a ComInterop? Or am i missing something?
The object browser shows Encore.Utilites is defined as follows
-- Interop.Encore
{} Encore
Instance (an enum)
IQuery (interface)
ISetup (interface)
ITransaction (interface)
IUtilities (interface)
Language (enum)
LogDetail (enum)
Query (class)
Setup (class)
Transaction (class)
Utilities (class)

Thanks for any help.
asked by jimmyseow123 (4.6k points)

3 Answers

0 votes
To help I need to following information.

Where is Encore defined?, what is its namespace and what library do you have to reference?

What version of TypeMock are you using?
answered by scott (32k points)
0 votes
The namespace of the Encore.Utility is Encore. The class is Utility. As can be seen in the class structure I drew in my posting. Encore is a member of Interop.Encore assembly. It's actually a COM object.
I'm using the latest version of TypeMock according to the TypeMock Configuration|About screen in Visual Studio.
answered by jimmyseow123 (4.6k points)
0 votes

It's actually a COM object.

I can't find this assembly on my computer, but if it is an unmanaged COM object, TypeMock will not be able to mock it.
answered by scott (32k points)