Sometimes I want to just verify that a function was called rather than have to test the function was called with specific parameters.
The reason for this that there is a complex object being passed in as a parameter, but the later call inside that function makes a database fetch. Since this will be mocked, it will just have nulls & 0s.
I just want to verify the call without testing against the passed in parameters. How can I do this?
You may find the following blog post useful. Quote:
myMockedClass.Verify(
x => x.Connect(It.IsAny<MyArgumentType>())
);
Related
I have this issue that I want to solve.
I want to create a new http request using field from previous response
I send a request
I used Json extractor to move the response string to a variable (let call this string nurl)
I used Regular expression and move the field that I want to "Reference Name"
(meanning from nurl I just want tt_cid)
Now I want to make a new call, and use that field tt_cid in my new call
How I shall call tt_cid? since it is not passed as User Defined Variables,
when I use tt_cid, I do not think J meter know it, since it is not written there, I just pulled it from the response.
Provided a Pic of what I have done
Regards to you all
Short answer call it ${tt_cid}.
since it is not passed as User Defined Variables, when I use tt_cid,
I do not think J meter know it,
For your understanding add Debug Sampler after Regular expression,
You will see all your JMeter variables, including tt_cid, which can be called as other variables ${tt_cid} inside other Samplers.
It's called Reference Name and not Variable Name because it's more complicated, You should read JMeter's Regular Expression to understand how it works internally, But basically it saves more than just 1 Variable.
So there is this HUGE JSON that I am loading from a file and than I run it through lr_eval_string and save it to a parameter. This parameter is later used as a body in one of my REST calls.
I use lr_eval_string to dynamically replace different values in that JSON.
Now here is the problem, one of the values that I replace is unique and generated by a c function. This value appears numerous times in that JSON and needs to be unique each time, yet I am only able to call that c function once at the beginning of the action. The result is that all values end up being equal...
So my question is: how can I call my function each time this unique value appears? I am talking about functionality similar to "Update value on: Each occurrence" that is available on the Parameters section.
I see an option called "User Defined Function" in parameters which I guess could do what I am looking for yet I couldn't find any good tutorial on how to actually use this functionality. Is user defined action the way to go, is there any other solution?
Any help would be highly appreciated! :)
I'm running in to an issue in that I need to get one value in a cucumber statement, and then give that value to another statement.
Specifically I am getting a JSON object from one page (where that object gets sent to an api endpoint as a preference) and then using information out of that after I query the api, which happens in a completely separate step.
I am suspecting that I have to write the value somewhere, and then pull that value when the step that needs it comes up, but I'm kind of at a loss for doing that as well.
I can provide any further needed details, thanks for any help!
Definitely a rookie question - to which the answer is to use instance variables - #variable_name = get_method in the helper method your step calls.
I've a situation where i get some information from database and based on the data , i want to do/forward to some other controller & action.
How can i do this using Yii? Its like an ajax request..
If i can use the CController->forward() , then how can use the post values for actions?
I shall assume that the reason why redirect() didn't work for you was because you can't sent post variables with it. If that's the case, then let me show you how to overcome the lack of POST support in redirect(). You can use setState(). It creates variables that simulate POST variables. This is the code to store or set a variable:
Yii::app()->user->setState('var', 'value');
And, in order to trace the value you just code as follows:
Yii::app()->user->getState('param1');
It would equally work with forward, but I'm not sure why you want to use it instead of redirect().
I have a huge controller in codeigniter, with many functions. I want to limit access to certain functions. How should I proceed?
And can I call the functions using cron daemon???
Or should I place those functions in another controller??
a) To limit the access to functions in your controller you shold use private function declaration example:
function _example_function() {...} USING the underscore!!
This way its impossible to call this function by URL.
b) Other simple way to restrict the access to functions in your controller is to use session variables and states to block the access.
2.) Yes you can use cron to run function just call the URL:
http://host/controller_name/FUNCTION
Regards,
Pedro
I have a huge controller in
codeigniter, with many functions. I
want to limit access to certain
functions. How should I proceed?
You can use some access control based on session to limit access to certain controllers->functions only. At the start of the function you can place the code like if($_SESSION['user'] != 'xyz') exit('access denied') ;
And can I call the functions using
cron daemon???
yes you can call any controller function in cron with this command
wget https://www.example.com/controller-name/function-name
Or should I place those functions in another controller??
Its always a good idea to refactor the code if its getting very big and getting unmanageable.
Another way is to use the protected namespace. When I try calling a function which is marked as protected I'm able to use it within the PHP code yet when trying to load it trough the browser I receive a 404.
Of course marking it as private would work too, but then you'd loose the ability to use the function within an extension of your class. When working with core extensions a lot that would be a problem.
cu
Roman