Je suis en train de monter des tests unitaires et je dois tester une méthode qui peut appeler successivement une autre méthode à plusieurs reprises mais avec des données différentes dans l'entité passée en paramètre.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 
    Function Identification(ByVal criteresRecherche As IdentificationG3.CritRechParticulierEntite) _
        As IdentificationG3.LiaisonG3ResultatIdentificationEntite Implements ITraiterDemandeVADA.Identification
 
        Dim retourG3 As IdentificationG3.LiaisonG3ResultatIdentificationEntite = Nothing
        Dim criteres As IdentificationG3.CritRechParticulierEntite
 
        If Not String.IsNullOrEmpty(criteresRecherche.NoUsager) AndAlso criteresRecherche.DateNaissance.HasValue Then
 
            criteres = New A102_ENT.IdentificationG3.CritRechParticulierEntite
            criteres.AnImposi = criteresRecherche.AnImposi
            criteres.CodeUTA = criteresRecherche.CodeUTA
            criteres.NoUsager = criteresRecherche.NoUsager
            criteres.DateNaissance = criteresRecherche.DateNaissance
            retourG3 = AgentServiceAutreSys.AgentServiceG3.Identifier(ConvertirCritRechEnLiaisonG3(criteres))
        End If
 
        If (retourG3 Is Nothing OrElse _
            (retourG3.RetourIdentification.CodeResultatIdentification.HasValue AndAlso _
             retourG3.RetourIdentification.CodeResultatIdentification <> 1)) AndAlso _
            criteresRecherche.Nas.HasValue AndAlso criteresRecherche.DateNaissance.HasValue Then
 
            criteres = New IdentificationG3.CritRechParticulierEntite
            criteres.AnImposi = criteresRecherche.AnImposi
            criteres.CodeUTA = criteresRecherche.CodeUTA
            criteres.Nas = criteresRecherche.Nas
            criteres.DateNaissance = criteresRecherche.DateNaissance
            retourG3 = AgentServiceAutreSys.AgentServiceG3.Identifier(ConvertirCritRechEnLiaisonG3(criteres))
        End If
 
        If (retourG3 Is Nothing OrElse _
            (retourG3.RetourIdentification.CodeResultatIdentification.HasValue AndAlso _
             retourG3.RetourIdentification.CodeResultatIdentification <> 1)) AndAlso _
            Not String.IsNullOrEmpty(criteresRecherche.NomFamille) AndAlso _
            Not String.IsNullOrEmpty(criteresRecherche.Prenom) AndAlso _
            criteresRecherche.DateNaissance.HasValue Then
 
            criteres = New A102_ENT.IdentificationG3.CritRechParticulierEntite
            criteres.AnImposi = criteresRecherche.AnImposi
            criteres.CodeUTA = criteresRecherche.CodeUTA
            criteres.NomFamille = criteresRecherche.NomFamille
            criteres.Prenom = criteresRecherche.Prenom
            criteres.DateNaissance = criteresRecherche.DateNaissance
            retourG3 = AgentServiceAutreSys.AgentServiceG3.Identifier(ConvertirCritRechEnLiaisonG3(criteres))
        End If
 
        If (retourG3 Is Nothing OrElse _
            (retourG3.RetourIdentification.CodeResultatIdentification.HasValue AndAlso _
             retourG3.RetourIdentification.CodeResultatIdentification <> 1) _
            OrElse (retourG3.RetourIdentification.NiveauFiabiliteIdentification.HasValue AndAlso _
                    retourG3.RetourIdentification.NiveauFiabiliteIdentification > 4)) AndAlso _
            Not String.IsNullOrEmpty(criteresRecherche.NomFamille) AndAlso _
            Not String.IsNullOrEmpty(criteresRecherche.Prenom) AndAlso _
            (Not String.IsNullOrEmpty(criteresRecherche.Appartement) OrElse _
                Not String.IsNullOrEmpty(criteresRecherche.NoCivique) OrElse _
                Not String.IsNullOrEmpty(criteresRecherche.Rue) OrElse _
                Not String.IsNullOrEmpty(criteresRecherche.Ville) OrElse _
                Not String.IsNullOrEmpty(criteresRecherche.Province) OrElse _
                Not String.IsNullOrEmpty(criteresRecherche.CodePostal)) Then
 
            criteres = New A102_ENT.IdentificationG3.CritRechParticulierEntite
            criteres.AnImposi = criteresRecherche.AnImposi
            criteres.CodeUTA = criteresRecherche.CodeUTA
            criteres.NomFamille = criteresRecherche.NomFamille
            criteres.Prenom = criteresRecherche.Prenom
            criteres.Appartement = criteresRecherche.Appartement
            criteres.NoCivique = criteresRecherche.NoCivique
            criteres.Rue = criteresRecherche.Rue
            criteres.Ville = criteresRecherche.Ville
            criteres.Province = criteresRecherche.Province
            criteres.CodePostal = criteresRecherche.CodePostal
            retourG3 = AgentServiceAutreSys.AgentServiceG3.Identifier(ConvertirCritRechEnLiaisonG3(criteres))
        End If
 
        Return retourG3
 
    End Function
Je voudrais mocker la méthode Identifier qui est appelée à plusieurs reprises, comment faire?

Merci.