c# - Faking a generic method FakeItEasy -
c# - Faking a generic method FakeItEasy -
how go faking following:
public interface iblah { func<t, bool> applyfilter<t>(func<t, bool> predicate) t:imessage; }
what false homecoming it's argument without changes. however, verify false has been called once. utilize case given below:
public class { public something(iblah blah) { _blah = blah; } public bool dosomething(somevalue m, func<somevalue, bool> predicate) { func<somevalue, bool> handler = _blah.applyfilter(predicate); homecoming handler(m); } }
i.e. false needs deed pass through need able verify it's been used.
what's best way go this?
[please don't worry contrived example...there's lot of things going on under covers, i've simplified downwards illustration above.]
would solve issue? pass through predicate , verify applyfilter called once
[fact] public void testfeature() { var false = a.fake<iblah>(); a.callto(() => fake.applyfilter(a<func<int, bool>>.ignored)).returnslazily(x => { homecoming x.getargument<func<int, bool>>("predicate"); }); var = new something(fake); var result = something.dosomething(1, x => x > 1); assert.false(result); a.callto(() => fake.applyfilter(a<func<int, bool>>.ignored)).musthavehappened(repeated.exactly.once); }
c# fakeiteasy
Comments
Post a Comment