fakeiteasy


FakeItEasy mocked method won't return object, instead nullReferenceException


What I'm trying to do
I want a method, GetDirectoryInfo on a faked interface called fakeHiveReader to return a DirectoryInfo object.
I have to use the constructor to create the DirectoryInfo object I want to return, because that constructor calls a protected constructor for the parent class.
It's important that the method returns this specific DirectoryInfo object, so that I can check that later on, this object is used as a parameter for an important method.
The problem
The object is created fine, and I can see using breakpoints that the constructor is working, but then the last line throws an exception. If you run debug it stops on the line with a "NullReferenceException was unhandled by user code" pop-up. If you "View Detail" it says "System.NullReferenceException" and "Object reference not set to an instance of an object."
Any ideas would be hugely appreciated.
var fakeHiveReader = A.Fake<IHiveReader>();
DirectoryInfo di_1 = new DirectoryInfo(3, 4, "\\GeoWoods", "Gwood2", "Good", DateTimeOffset.UtcNow, true);
A.CallTo(() => fakeHiveReader.GetDirectoryInfo(#"\")).Returns(di_1);

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
yii2
openlayers
wso2
coq
omnet++
plone
plot
hp-exstream
framework7
filtering
paw-app
graphql
webpack-2
sql-server-2016
installshield
cross-browser
fingerprint
flyway4
azure-media-services
append
medical
iggrid
reveal.js
row
correlation
collectd
serilog
reactcsstransitiongroup
reactive-cocoa
dbext
buildbot
user-interaction
brunch
filezilla
strncpy
gsmcomm
stringtemplate
gammu
mapbox-gl
vxworks
lto
xenforo
fedex
isbn
no-www
netcdf4
modelmapper
eclipse-gef
galleria
azure-application-gateway
prolog-setof
jquery-validate
blogengine.net
slickedit
pg-dump
np-complete
qtwebview
zendesk-app
gcsfuse
bind9
sonarlint-vs
deadbolt-2
angular-cache
passport-google-oauth
fody
skobbler-maps
mongocsharpdriver
simplewebrtc
dlna
ios4
pervasive-sql
msys
thredds
marching-cubes
mutation-observers
content-length
ideamart
php-ci
operation
generic-programming
clipperlib
nsmutabledictionary
block-device
typekit
mdt
device-manager
document-classification
p4java
htmlcleaner
rtmfp
algebraic-data-types
apc
back-stack
dataadapter
mylyn
sharp-repository
e4x
pvrtc
first-responder
armcc
qtkit
punbb
bigcouch
transactionscope
spyware
invite
servicehost
pyinotify
yslow
fluent-interface
xetex
w3wp
ugc

Resources

Encrypt Message