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
image-processing
kde
mfc
relay
q
rubygems
jpeg
sql-server-2016
fingerprint
swagger-ui
cross-validation
webrequest
adfs
wheelnav.js
seaborn
reactcsstransitiongroup
google-pagespeed
custom-wordpress-pages
orleans
sylius
crystal-reports-2010
bootstrap-material-design
fopen
gitignore
lightswitch-2013
react-chartjs
.net-4.0
exuberant-ctags
pdb
siesta-swift
hybridauth
web-mining
swift3.0.2
bootstrapper
gulp-sourcemaps
scorm
upstart
rails-routing
dropbox-php
togetherjs
colorama
carrot
composite-key
flutterwave
mcafee
nxt
rotativa
fody
transmitfile
firebaseui
flash-cs5
lua-5.1
suffix-tree
nessus
php-parse-error
javax.sound.midi
hsv
prerequisites
python-3.2
security-testing
tarjans-algorithm
rgeo
android-listview
operation
ami
oberon
angular-local-storage
sonarqube5.1.2
truevault
umbraco6
nsmutabledictionary
rake-task
operator-precedence
tablelayout
coldbox
tt-news
cdt
android-nested-fragment
elliptic-curve
jubula
rebol3
seaside
oracle-warehouse-builder
message-driven-bean
viadeo
intentservice
flexmojos
multiprocessor
farseer
geos
ivyde
blending
flash-builder4.5
xamlparseexception
jelly
clipper
chuck
runas
frameset
dotnethighcharts
stage
deobfuscation
rfc1123
yui-datatable
.nettiers
modelstate
bespin
database-management
meego
microsoft-virtualization
javap
text-coloring
rtml

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