fakeiteasy


How to fake delegates with FakeItEasy


When i try to fake a delegate-type, i get System.InvalidCastException
[TestMethod]
public void TestDelegateFake()
{
var func = A.Fake<Func<long, object>>();
A.CallTo(() => func(A<long>.Ignored))
.Returns(new {});
func(123);
}
How du i fake delegates?
I think you have to specify the Invoke-method explicitly:
A.CallTo(() => func.Invoke(A<long>.Ignored)).Returns(new {});

Related Links

Converting an MOQ property setup to FakeItEasy
Howto loop OrderedAssertions in FakeItEasy 2
FakeItEasy setting property with no get accessor?
FakeItEasy mocked method won't return object, instead nullReferenceException
How to specify the class to use when faking a property?
How can I fake a Class used insite SUT using FakeItEasy
FakeItEasy expectation fail against HashSet comparisons
FakeItEasy AssignsOutAndRefParameters - lazily?
How do I find the underlying Type of a Fake object returned from FakeItEasy?
FakeItEasy ReturnsLazily with out parameter
how to verify that a method was called with an argument of a specific type
How to fake delegates with FakeItEasy
FakeItEasy & “params” arguments
Using Expression Trees as an argument constraint
How to update a property on a parameter using FakeItEasy

Categories

HOME
java
wso2-am
hook
urbancode
activiti
dictionary
tinymce
dot
relay
google-oauth
spring-jdbc
twitter-bootstrap-4
packages
icloud
cloudkit
maude-system
moonmail
event-handling
fallback
foselasticabundle
serilog
pugjs
invantive-sql
nodatime
jasonette
accessor
java-7
smb
buildbot
facet
tooltipster
neo4j-spatial
phonegap
column-family
bytecode-manipulation
dynamics-crm-2013
occlusion
bootstrapper
graphenedb
sfdc
elmah
eclipse-gef
sencha-touch-2.3
google-datalayer
menuitem
python-c-api
python-webbrowser
alphabet
veracode
statsd
google-perftools
np-complete
media-player
messenger
ableton-live
url-pattern
nxt
dstu2-fhir
mongocsharpdriver
pagedlist
actionbardrawertoggle
qcustomplot
dataview
r-tree
cyclomatic-complexity
muse
apache-commons-fileupload
facebook-graph-api-v2.4
tween
java.util.concurrent
file-copying
rebol3
android-2.2-froyo
pyhdf
xsockets.net
access-rights
listings
odata4j
tws
html4
selected
frameset
word-processor
propertyeditor
newtonscript
bubble-chart
mod-auth
xmemcached
oncheckedchanged
xfbml
nhibernate.search
sector

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App