jeudi 5 février 2015

Unit Testing using Microsoft Fakes - Skipping a function

SO , here i am writing unit test cases for my project. I am stuck at one point where i am having a function call that has ref parameter. Example :-


public decimal addToSubtractFromCheckAmount(decimal dChkAmt,ref ICharge oCharge, bool blnAddTo, bool blnIncludeRBL)


I am writing a test case of a function that calls the above function (addToSubtractFromCheckAmount) and i want to skip it and provide my custom return value.


** using(ShimsContext.Create())



ShimClassName.AllInstances.addToSubtractFromCheckAmountDecimalIChargeBooleanBoolean
= (a, b, c, d, e) => new decimal(20);


** This works when i do not pass a ref parameter, but when i gave ICharge interface a ref keyword, the function disappears from my Unit Test case class metadata. Many websites talk about SHIMMING functions that has string ref parameters, but not of interfaces, Collections, etc.


I am stuck on this for some time now. Can someone help? Please let me know if you guys need more info, Thanks.


Aucun commentaire:

Enregistrer un commentaire