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
sendgrid
log4j
jdo
magnific-popup
json.net
office365api
google-docs
at-command
spring-jdbc
jpeg
callback
wamp
datastax-java-driver
constraint-programming
virtualization
cloudkit
spring-xd
collectd
spring-tool-suite
flask-wtforms
after-effects
http-status-code-504
jqwidget
jquery-ajaxq
arabic
tapestry
tdd
su
spark-jobserver
compatibility
unboundid
lightswitch-2013
media-queries
typed.js
protovis
automake
mixture-model
android-fingerprint-api
angularjs-factory
lumberjack
unoconv
android-tabhost
google-closure
keydown
http-redirect
flashair
slick-3.0
network-flow
react-scripts
theming
nodebb
sonarlint-vs
query-performance
crosswalk-runtime
medium.com
url-pattern
trash
paypal-express
storekit
testng-dataprovider
ios4
uid
execute
prerequisites
msys
cartesian-product
lemon
dukescript
lustre
codeigniter-url
id3v2
php-5.4
terminfo
message-driven-bean
ms-project-server-2010
seed
chuck
funscript
errai
calling-convention
inotifycollectionchanged
infrastructure
gamma
ext3
xetex
django-notification
wsdl.exe
misv

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App