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
bluetooth
nullpointerexception
angular-material
syntax
bpmn
at-command
rsync
yahoo-oauth
blueprintjs
upload
basic
gitpitch
cloudkit
qt-creator
postgres-xl
commonmark
dtrace
visual-studio-cordova
decimal
clearcase-ucm
vaadin7
worldwind
windows-7-x64
facebook-page
aurigma
invantive-sql
samoa
visual-composer
spark-jobserver
bootstrap-duallistbox
entitlements
fifo
spring-mybatis
primitive
nameservers
galsim
.net-4.0
scorm2004
gtrendsr
kendo-ui-grid
asset-pipeline
rotational-matrices
normal-distribution
wpf-controls
vxworks
hot-module-replacement
espeak
trim
quadratic-programming
google-closure
http-live-streaming
import-from-excel
sage-one
togetherjs
slickedit
flow-control
gcsfuse
nested-sets
xcb
wdf
login-control
nsviewcontroller
persist
thredds
iis-arr
service-accounts
appfabric-cache
skos
nsmutabledictionary
asp.net-web-api-odata
id3v2
navigationservice
jquery-layout
uv-mapping
mysqltuner
android-screen-support
comaddin
limejs
flashvars
typoscript2
libstdc++
nsnetservice
windows-phone-7.1.1
removeclass
blackberry-playbook
rfc1123
revisions
fixed-width
meego
swing-app-framework
procedural-music

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