J'ai CLAS qui est quelque chose comme çaRhinoMocks: comment tester si la méthode a été appelée lors de l'utilisation PartialMock
public class MyClass
{
public virtual string MethodA(Command cmd)
{ //some code here}
public void MethodB(SomeType obj)
{
// do some work
MethodA(command);
}
}
Je moqué MyClass comme PartialMock (mocks.PartialMock<MyClass>
) et l'attente de configuration I pour METHODA
var cmd = new Command();
//set the cmd to expected state
Expect.Call(MyClass.MethodA(cmd)).Repeat.Once();
Le problème est que MethodB appelle l'implémentation actuelle de MethodA au lieu de se moquer d'elle. Je dois faire quelque chose de mal (pas très expérimenté avec RhinoMocks). Comment puis-je le forcer à se moquer de MetdhodA?
Voici le code actuel:
var cmd = new SetBaseProductCoInsuranceCommand();
cmd.BaseProduct = planBaseProduct;
var insuredType = mocks.DynamicMock<InsuredType>();
Expect.Call(insuredType.Code).Return(InsuredTypeCode.AllInsureds);
cmd.Values.Add(new SetBaseProductCoInsuranceCommand.CoInsuranceValues()
{
CoInsurancePercent = 0,
InsuredType = insuredType,
PolicySupplierType = ppProvider
});
Expect.Call(() => service.SetCoInsurancePercentages(cmd)).Repeat.Once();
mocks.ReplayAll();
//act
service.DefaultCoInsurancesFor(planBaseProduct);
//assert
service.AssertWasCalled(x => x.SetCoInsurancePercentages(cmd),x=>x.Repeat.Once());