unit testing - A.CallTo method that uses expression as a parameter -
i'm trying this, , doesn't work, although kinda should be
a.callto(() => partyrepo.where(o => o.person != null)) .returns(new[] {new party()}); the call method exact code parameter returns empty enumerable
the reason expression you're passing in call specification , 1 that's sent partyrepo not equal. there's no way fakeiteasy determine if arguments use equals-method.
i'm not sure best workaround, this:
public static class myargumentconstraints { public static func<myclass, bool> returnstruewhenpersonisnotnull(this iargumentconstraintmanager<func<myclass, bool>> manager) { return manager.nullcheckedmatches(x => { return x.invoke(new myclass() {person = "person"}) && !x.invoke(new myclass() {person = null}); }, x => x.write("predicate returns true non null person")); } } public class myclass { public string person { get; set; } } with extension can rewrite original line:
a.callto(() => partyrepo.where(a<func<myclass, bool>>.that.returnstruewhenpersonisnotnull()) .returns(new[] {new party()});
Comments
Post a Comment