fakeiteasy


How to update a property on a parameter using FakeItEasy


I have an interface that includes a member that looks like:
void ExecuteSqlCommand(string procedureName, SqlParameter[] parameters);
I am using FakeItEasy to create a mock of this to pass to one of my classes.
The code I am testing calls this method, then checks the value of one of the SqlParameters. How do I use FakeItEasy to set the Value property of this parameter when the method is called?
I appreciate that this is probably not the best practice for getting individual pieces of information out of a database, but I am working with existing stored procedures, some of which have OUT parameters.
As you say, this is probably not the best practice. That aside, i guess you could do something like this:
A.CallTo(() => fake.ExecuteSqlCommand(A<string>._, A<SqlParameter[]>._)).Invokes(x =>
{
x.GetArgument<SqlParameter[]>(1)[indexOfTheParameterYouWantToSet].Value = yourValue;
});

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
testing
ionic-framework
jdo
netsuite
deezer
tizen
path-finding
stock
jira
amazon-ecs
youtube-api-v3
azure-storage-tables
synchronization
applepay
slurm
iggrid
gorm
adobe-analytics
n-gram
usergrid
messages
quartz-scheduler
workload-scheduler
telephony
text-rendering
functional-testing
ehcache
excel-2007
kudan
java-7
angular2-aot
xpages-ssjs
qhull
linkerd
compatibility
tasklet
delicious-api
caret
framemaker
normal-distribution
mpmediaquery
mapdb
hilbert-curve
xenforo
impersonation
core-plot
http-live-streaming
password-encryption
s
cubic-spline
angular-resource
komodoedit
rails-routing
paxos
dandelion
datastax-startup
dropbox-php
setter
knockout-components
windows-mobile-6.5
flutterwave
spring-mongodb
redundancy
pycaffe
azure-sdk
probability-density
measures
mathematica-frontend
make-install
pickadate
freedesktop.org
hsv
intel-fortran
google-places
marching-cubes
browser-bugs
deis
processmodel
proj4js
umbraco6
bigbluebutton
python-green
gadt
knuth
relocation
markers
neolane
flask-cors
uitouch
rtmfp
bundles
android-2.2-froyo
centos5
openlaszlo
tws
sqlperformance
mqx
pygit2
eventlistener
runas
hosts-file
wse3.0
bigcouch
doh
zpt
coercion
table-footer
actionview
propagation
oncheckedchanged
imac
remember-me
fluent-interface
blitz++
vc90
ext3

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