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
magnific-popup
mfc
appx
lodash
electron
youtube-api-v3
mvvmcross
echarts
opengl-es-2.0
azure-media-services
paradox
android-youtube-api
synchronization
nano-server
volttron
quicklook
windows-azure-storage
usergrid
visual-studio-cordova
flask-wtforms
windows-server-2012
foselasticabundle
windows-7-x64
interop
crystal-reports-2008
custom-wordpress-pages
object-detection
core-text
blazemeter
librato
gsoap
media-queries
ecto
bosh
key-value-observing
google-cloud-endpoints-v2
twilio-api
exuberant-ctags
kendo-ui-grid
pim
perlin-noise
webtest
ghost4j
environment-modules
swift3.0.2
objectlistview
hilbert-curve
elasticsearch-plugin
hp-ux
g-code
google-closure
businessworks
avconv
logparser
python-webbrowser
hls.js
integrity
svmlight
nstextview
sqldf
iso8601
color-profile
ableton-live
log4c
gridview-sorting
master-slave
python-stackless
xpath-1.0
srand
content-length
drawbitmap
cakephp-3.1
vstest.console.exe
key-management
clipperlib
javax.mail
website-monitoring
rdtsc
gulp-less
project-planning
has-many-through
jquery-layout
undefined-reference
resty-gwt
algebraic-data-types
html5-notifications
farseer
aqtime
jmapviewer
dotnetnuke-5
jplaton
dataadapter
eventual-consistency
orchardcms-1.7
cisco-jtapi
regsvr32
reddot
code-cleanup
nsdatecomponents
php-parser
vdsp
cinema-4d
pyinotify
lang
google-friend-connect
gamequery
dbal
castle-monorail
microsoft-virtualization
ubuntu-9.04
grid-system

Resources

Encrypt Message