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
If I try to mock a call to a shared method


   Public Shared ReadOnly Property GetListAccessoiresTypes(Optional ByVal pReset As Boolean = False) As TList(Of AccessoiresTypes)
            Get
                Dim list As TList(Of AccessoiresTypes)

                If Accessoirestypes Is Nothing Or pReset Then
                    list = DataRepository.AccessoiresTypesProvider.GetAll.FindAll(Function(c As AccessoiresTypes) CBool(c.Active) = True And String.IsNullOrEmpty(c.Code) = False)
                    Accessoirestypes = list
                Else
                    list = Accessoirestypes
                    list.RemoveFilter()
                End If
                Return list
            End Get
        End Property



I get an error

You are using TheseCalls.ReturnValue incorrectly - Method get_GetListAccessoiresTypes in type xxx.xxx.listes does not return a value

My test method is

 Dim target As AccessoiresCategoriesPlus = New AccessoiresCategoriesPlus() ' TODO: Initialize to an appropriate value

            Dim oldMarge As [Decimal] = New [Decimal](0.5)
            Dim newMarge As [Decimal] = New [Decimal](0.6)
            target.Marge = oldMarge

            Dim listAT As New TList(Of AccessoiresTypes)

            Using TheseCalls.WillReturn(listAT)
                Dim list = Listes.GetListAccessoiresTypes()
            End Using


            target.AjusterMarge(oldMarge, newMarge)
            Assert.AreEqual(target.Marge, newMarge)


I am just getting started and some help would be greatly appreciated.
asked by RedSoxFred (1.8k points)

3 Answers

0 votes
Hi Fred,

We haven't been able to recreate this error. Which version of Isolator Do you use?
Can you please send me the code of AjusterMarge() ?
answered by alex (18k points)
0 votes
I am using the latest available version which I downloaded from your website last Wednesday.

        Sub AjusterMarge(oldMarge As Decimal, newMarge As Decimal)
            Try
                If Marge <> newMarge Then
                    Marge = newMarge
                End If

                For Each at As AccessoiresTypes In Listes.GetListAccessoiresTypes(True).FindAll(Function(o) o.ActId = Id)
                    If at.Marge = oldMarge Then
                        Dim atp As New AccessoiresTypesPlus(at)
                        atp.AjusterMarge(oldMarge, newMarge)
                    End If
                Next
            Catch ex As Exception
                ErrorLogging.LogError(ex, "AccessoiresCategoriesPlus", MethodBase.GetCurrentMethod.Name)
            End Try
        End Sub
answered by RedSoxFred (1.8k points)
0 votes
Hi,

Assuming that TList inherits List(Of AccessoiresTypes), AjusteMarge() behaves as follows:
1) There was no exception thrown from the try block which means we never entered the catch block.
2) Inside the try block, we entered the while loop based on how we set the list("Listes: in your code).

So, we still can't recreate the error.
Can you please send us a complete code sample which would demonstrate the error( I mean a VS solution with compiling code).

Thank you for cooperation
answered by alex (18k points)
...