Mon simulacre dynamique se comporte comme un simulacre de Parial, signifiant qu'il exécute le code réel lorsqu'il est appelé. Voici les façons je l'ai essayéQuestion de DynamicMock de Rhinomocks
var mockProposal = _mockRepository.DynamicMock<BidProposal>();
SetupResult.For(mockProposal.CreateMarketingPlan(null, null, null)).IgnoreArguments().Repeat.Once().Return(
copyPlan);
//Expect.Call(mockProposal.CreateMarketingPlan(null, null, null)).IgnoreArguments().Repeat.Once().Return(
// copyPlan);
// mockProposal.Expect(x => x.CreateMarketingPlan(null, null, null)).IgnoreArguments().Return(copyPlan).Repeat.Once();
Au lieu de retourner ce que je pense qu'il exécute le code dans la méthode CreateMarketingPlan
Voici l'erreur:
System.NullReferenceException: Object reference not set to an instance of an object.
at Policy.Entities.MarketingPlan.SetMarketingPlanName(MarketingPlanDescription description) in MarketingPlan.cs: line 76
at Policy.Entities.MarketingPlan.set_MarketingPlanDescription(MarketingPlanDescription value) in MarketingPlan.cs: line 91
at Policy.Entities.MarketingPlan.Create(PPOBenefits ppoBenefits, MarketingPlanDescription marketingPlanDescription, MarketingPlanType marketingPlanType) in MarketingPlan.cs: line 23
at Policy.Entities.BidProposal.CreateMarketingPlan(PPOBenefits ppoBenefits, MarketingPlanDescription marketingPlanDescription, MarketingPlanType marketingPlanType) in BidProposal.cs: line 449
at Tests.Policy.Services.MarketingPlanCopyServiceTests.can_copy_MarketingPlan_with_all_options() in MarketingPlanCopyServiceTests.cs: line 32
Mise à jour: J'ai compris Ce que c'était. La méthode n'était pas "virtuelle", donc on ne pouvait pas la tourner en dérision car les méthodes non-virtuelles ne peuvent pas être mandatées.
Pouvez-vous s'il vous plaît poster et accepter votre solution? Cela l'empêchera de rester une question ouverte. –
Ceci doit être marqué comme répondu. – Kehlan