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
0 votes
Hi,

In our company we use typemock to test some of our code, and we have a server that do continues integration. We use FinalBuilder/CruiseControl to build our code evertime there have been checked in some changes to the code, and then all tests are run.
(The server is 64-bit)

In one of our tests we try to mock some call to a fillAll procedure that is filling a collection from a database.

TestCode:
 Dim _mockObjectCollection As New SubscriptionCollection
           
 Using recorder As New RecordExpectations
        Mercatus.Common.Data.BusinessObjects.BusinessObjectDataProvider.Instance.FillAll( _
                    _mockObjectCollection)
End Using

'Execute code:
 Dim s As String = SubscriptionController.ProcessSubscriptions()


In SubscriptionController.ProcessSubscriptions() we have this call, where typemock fails to mock, subscriptions.FillAll()

 <System.ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Select, True)> _
        Public Sub FillAll() Implements IBusinessObjectCollection.FillAll
            DataProvider.FillAll(Me)
        End Sub


And that is calling this code which we try to mock in our recorder.

 ''' <summary>
        ''' Populate a businessObjectCollection from datastorage, by a select *
        ''' </summary>
        ''' <param name="itemCollection">The businessObjectCollection to populate</param>
        Public Sub FillAll(ByVal itemCollection As IBusinessObjectCollection)
            If itemCollection Is Nothing Then
                Throw New ArgumentNullException("itemCollection")
            End If

            Using reader As DbDataReader = DataMapper.ListAll(itemCollection.ItemObjectName)
                PopulateCollectionFromReader(reader, itemCollection)
            End Using
        End Sub


This works fine when we are running it on our developer machines, but sometimes fails when we run it in our server that runs our builds.

The error we get is that it can not open database (which is not created hence the mocking).

The strange thing is that this is not consistent, sometimes the mocking is ok, and somtimes it is not mocking. (It is more correct than wrong!!)

And in most cases a new force build solves the problem.


Are we doing something wrong in our test, or is this a bug?

Are there some logging in typemock we can turn on to get more information?

On the same server we run multiple projects on different build scripts that use TypeMock to run their unittests. But they are not running simultainously.

Regards
Magne Hopland
asked by Findulias (1.8k points)

2 Answers

0 votes
Hi
I'm still missing more data to see the full picture.
Here are some questions:
1. What is BusinessObjectDataProvider.Instance? is it a Property or a field?
What does it returns?
2. What is the class of
Public Sub FillAll() Implements IBusinessObjectCollection.FillAll ?
3. What is the class of Public Sub FillAll(ByVal itemCollection As IBusinessObjectCollection) ?

If you wish to send a running solution or the source code of the tested code
please tell me and I will send you my address.
answered by ohad (35.4k points)
0 votes
Hi thank you for quick response:

1. What is BusinessObjectDataProvider.Instance? is it a Property or a field?

It is a property of type BusinessObjectDataProvider
 Public Shared ReadOnly Property Instance() As BusinessObjectDataProvider
            Get
                If _instance Is Nothing Then
                    _instance = New BusinessObjectDataProvider
                    Return _instance
                Else
                    Return _instance
                End If
            End Get
        End Property


This BusinessObjectDataProvider is a common dataprovider for all our collections, and contains methods to store/delete/Fill a collection to/from a database.

2. What is the class of
Public Sub FillAll() Implements IBusinessObjectCollection.FillAll ?

BusinessObjectCollection

3. What is the class of Public Sub FillAll(ByVal itemCollection As IBusinessObjectCollection) ?

BusinessObjectDataProvider


This is probably still confusing, if you give me your email, i can send you the code.
answered by Findulias (1.8k points)
...