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
java
pandas
vbscript
pypi
activiti
google-api-php-client
vmware
spagobi
microservices
jxls
ebean
uber-api
gorm
spring-kafka
spring-xd
timeout
hex-editors
percona
lombok
progressive-web-apps
highlight.js
solaris-10
nhibernate-envers
textfield
swingx
swiftlint
ml
clickonce
excel-2007
google-search-api
extjs5
core-text
vlsi
assistant
gitignore
gsmcomm
nat
xquery-3.0
airconsole
catel
calibre
asset-pipeline
language-concepts
html5-fullscreen
catalog
neuroscience
event-driven
abstract-class
occlusion
unspecified
az-application-insights
splice
lumberjack
elmah
powershell-dsc
s
angular2-meteor
jsch
flickr-api
rails-routing
recursive-datastructures
tactic
np-complete
lync-client-sdk
dwscript
eventkit
instant
slicknav
savon
file-writing
flash-cs5
persist
ready-api
python-stackless
intellij-14
riak-cs
dml
funcunit
system.net.webexception
didselectrowatindexpath
mcts
c18
listings
coverflow
jplaton
comaddin
orchardcms-1.7
drools-planner
specification-pattern
distutils
selected
anonymous-methods
unc
multipage
hosts-file
onsubmit
wse3.0
punbb
ecl
w3wp.exe
asp.net-mvc-areas
paster
infrastructure
thunderbird-lightning

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