I have a ProductRepository with 2 methods, GetAllProducts and GetProductByType, and I want to test the argument on GetProductByType. Internally, GetProductByType calls GetAllProducts and then filters the correct ones.
public virtual IEnumerable & lt; Products & gt; GetAllProducts () {// All product returns in memory, DB etc.} Public virtual IEnumerable & lt; Products & gt; GetProductsByType (String Type) {Return (from GetAllProducts (P) Select p.Type == Type P) .Oolist (); }
So in my trial I want to duplicate GetAllProducts calls, so it gives me a list of the prescribed products in the test, and then call the original GetProductsByType, which is the consumption GetAllProducts Hats
I'm trying something like code below, but the original GetProductByType has not been executed, it's mocked-out as well. I have a call in the typemock method that fixes it It is, but I can not understand it. any idea?
var copy = new fake & lt; Product Rippers & gt; (); Counterfeit. Setup (R = & gt; RGetAellProducts ()). Returns (new listing & lt; Products & gt; () {p1, p2, p3}); Var Results = Mock.Object. GetProductsByType ("Type1"); Assurance The first (2, the result.) (Calculated);
Set the callbase on your fake to the right Call it the basic virtual methods or properties , If they exist, and a canned value has not been set to return.
var mock = new mock & lt; ProductRepository & gt; () {CallBase = true};
Comments
Post a Comment