C# - Mocking Method Call With Out Param And No Return Value In Rhino Mocks?
Feb 9, 2010
So I've got this method called LoginUser:
public void LoginUser(out SystemUser userToLogin, string username)
Having just started with Rhino Mocks, I'm having a little trouble mocking a call and return value from this method while testing my Presenter code. What's the correct syntax in this instance?
View 1 Replies
Similar Messages:
Jul 7, 2010
here Im trying to write a test can I mock a HttpRequestBase to return post values like this? please help as its quite urgent, how can I acheive this?
var collection = new NameValueCollection();
collection.Add("Id", "1");
collection.Add("UserName", "");
[code]...
View 1 Replies
Apr 30, 2010
I have a webmethod that has three parameters:
public AuthenticationResult Authenticate(Enum type, string userName, string password) But the problem I had is that if a null/invalid enum is entered for the type variable it throws an error message.
So the obvious solution is to use a string/int instead but I am cannot do this as current users already use the existing webmethod.
So i was thinking:
public AuthenticationResult Authenticate(object type, string userName, string password) and handling the casting myself but the problem I had with this is that now my users do not have access to the Enum type.
So my question is can I publish the enum type without having it as a parameter/return value? Allow the client to access the Enum so they can pass it into the method. Would using a method that returned a type that was my enum work? Or is there a way to catch this custom error: (I dont think so as it appears to be on the client end when converting Enum to xml). The error is: (System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Instance validation error: '45465' is not a valid value for Enum.)
View 1 Replies
May 24, 2010
Microsoft Ajax can expose webservices which respond with json or xml depending on configuration. I would like to mock these services using soap ui. Using the wsdl I can do this to mock the services in the case where xml is returned, however how can I mock the response when JSON is returned?
View 1 Replies
Oct 8, 2010
XP Pro,aspnet 2, IIS, Oracle I have a primary webpage that displays a tab and some summary data. The tab uses an iframe and the summary data is loaded by an async WebMethod call back to C#. The iframe page takes a short while to load depending on how much data is in there (sometimes upto 20 seconds?). The WebMethod call, or at least the content of it, is very fast. BUT, the WebMethod call won't return until basically the iframe has finished loading.
I've verified through Fiddler that the browser is initiating both requests at basically the same time. It's initiating the iframe call first followed immediately by the WebMethod call within the same second. My understanding is that browsers are limited to only two calls at once.
If I set a breakpoint at the end of my WebMethod call (even commenting out ALL it's guts so it just returns an empty string), that breakpoint won't fire until the aspnet page serving up the iframe has finished. Using threads window, I see both calls at the server. I just don't understand why the server won't actually run the Webmethod call until the first call has finished. I've searched the code looking Monitor.Enter, lock, etc to make sure nobody has inserted any other type of blocking code and I can't find anything. I've basically emptied out the WebMethod call and it just returns a string, but no matter what I do, it just won't return as fast as it can. If I comment out the iframe, then the WebMethod call returns within 2 seconds. With the iframe, it "looks" like the the webmethod call won't return until the iframe has finished.
1) Does aspnet only process one request per aspnet session id? Is it FIFO? I figured the webserver would just process requests and return each request as fast as it can.
2) What else can I do to get that summary data to return faster (but not actually loading and putting the data into the very first primary page) ?
View 2 Replies
Sep 28, 2010
how can i return 401 error from a method return ActionResult?
View 1 Replies
Mar 4, 2010
I have an ActiveX object which extends some functions. I have a web page that loads the ActiveX object and calls its methods in Javascript. The ActiveX object has two method; the problem is that Javascript can successfully call one of them but fails to call the other; citing Object doesn't support this property or method which is nonsense because I made a VB6.0 application that successfully calls this other method, so the two functions are indeed extended correctly and performing their job. And yes, the Internet Explorer security zones are all set and everything, as I wrote above the javascript code can call one method but refuses to call the other.
View 1 Replies
Sep 14, 2010
I want to execute a certain piece of code by default before each web Method.
Without adding any extra code in each method how to achieve this?
I am calling this service from Win application.
View 1 Replies
Jan 25, 2011
I have a web method in my code behind:
[System.Web.Services.WebMethod]
public static string GetStateData(string state)
{
//this is where i want to call a javascript method "GetItems"
}
I have a javascript method that retrieves some values for me and I want to get use one of those values in my web method
function GetItems() {
var variable1= $("#<%=Item1.ClientID %> input:checked");
var variable2= $("#<%=Item2.ClientID %>").val();
return [variable1.text(), variable2.val(), variable2];}
I've searched for ways to call the javascript method from the web method but every time my search results in how to call a web method from javascript.
I did find this but it was done from the code-behind of a silverlight project and when I tried adding the correct reference to my code-behind it wasn't there
var result = HtmlPage.Window.Invoke("GetItems"); Is there a reference I'm missing?
View 2 Replies
Mar 26, 2016
$("#Name").on("blur", function() {
if (Name != "" && Name != null) {
var options = {
type: "POST",
url: "ApplyNow.aspx/CheckName",
[code]...
how to use the value of 'duplicate' in btnsunmit_click() from webmethod.
View 1 Replies
Aug 6, 2010
I will like to add Rhino Service Bus to my ASP.NET web application but using Ninject as the DI Container. So far all examples I keep seeing use Castle Windsor which I don't want to use since we already use Ninject.Are there any tutorials out there which show how to add Rhino Service Bus to an ASP.NET web application without a direct dependency on Castle Windsor (e.g. using Ninject)?
View 1 Replies
Nov 16, 2010
i use JSon to return allot of results when building a website, but find myself writing a a lot of code like this:
[Code]....
and then simply call this function with whatever IEnumerable results i have my question is would i be on the right lines here, what would be the best possible way to do this as it makes no sense to be writing in MVC and OOP but to keep rewriting code to just FROM ?
View 5 Replies
Oct 6, 2010
I have two files. The first file is called FinalImage.aspx and here is the code for that page:
<html>
<body>
<img src="newpage.aspx" />
</body>
</html>
newpage.aspx has the following code, based on Jason's sample in the comments below:
<%@ Page Language="C#" %>
<script runat="server" language="c#">
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "image/png";
byte[] data = System.IO.File.ReadAllBytes("http://mystatus.skype.com/smallclassic/eric-greenberg");
Response.OutputStream.Write(data, 0, data.Length);
Response.OutputStream.Flush();
Response.End();
}
</script>
If I call FinalImage.aspx I see a broken image.
If I call newpage.aspx directly, I get a "URI Formats are not supported error"
I think its close, though. this solution is needed to get around the fact that skype does not have an https option for its skype buttons which tell the status of the skype user. Creating this proxy page will allow this to work without causing a 'mixed' security alert in the browser.
View 5 Replies
Jul 20, 2013
I'm trying to do the equivalent of a "Are you sure you wish to delete?" and then if yes, return to a function in the aspx.vb code. Here is what I have:
Code:
<!-- ModalPopupExtender -->
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1" TargetControlID="btnCancel"
CancelControlID="btnCancelNo" OkControlID="btnCancelYes" OnOkScript="__doPostBack" BackgroundCssClass="modalBackground">
[Code] ....
And then on the form, the btnCancel does popup the menu, with Yes / No and the text "Are you Sure?"But, even though I have a button called "btnCancelYes", I cannot get the code in there to trigger. Ie:
Code:
Protected Sub btnCancelYes_Click(sender As Object, e As EventArgs) Handles btnCancelYes.Click
DeleteRecord()
End Sub
View 3 Replies
Nov 24, 2010
I have a class file called ShoppingCartClass.cs. Inside ShoppingCartClass I have a method called CanadaPostShipping.
CanadaPostShipping get passed a lot of variables and then builds an xml, sends it to CanadaPost url and gets back an xml file with the shipping rates.
I would like to pass the xml back to my webpage so in my web page I can check that it has status ok and then extract the information I need.
My testing calling routine looks like this:
[Code]....
The start of my CanadaPostShipping routine looks like this
[Code]....
This is my current ending spot in CanadaPostShipping....where I am getting back the correct xml from CanadaPost
[Code]....
As you can see I am saving it to my thumbdrive.....
What changes would I have to make to my calling routine and the method in the class to return xml "mydoc"?
View 1 Replies
Mar 9, 2011
I'm really new to ASP.Net and for a school project we have to create a login form. Now I have managed to create a login with LINQ doing the following:
[Code]....
And in my html page:
protected void Test_Click(object sender, EventArgs e)
{
if (Class1.Controle(Convert.ToInt32(txt1.Text), txt2.Text))
[Code]....
I was thinking something amongst those lines, but I can't call p.GebruikerWachtwoord. So I'm guessing this is completely wrong.I hope somebody can help me figure this out, and I apologise for the poor explanation, English isn't my native language.
View 3 Replies
Nov 5, 2010
When I click on the following div:
<div id="Result">Click here for the time.</div>
I need the following codebehind function to run:
<WebMethod()> _
Public Shared Function GetDate() As String
Return DateTime.Now.ToString()
End Function
I need this to populate the inside of the div with the string returned by the GetDate() function. I think this should use code similar to this:
[Code]....
I've pulled this example from this site: [Code]....
However, I simply cannot get it to work. Nothing happens. This is just a regular asp.net web project. I haven't done any sort of Ajax-enabling business other than including script tags in my markup to reference jquery.
Here's what the firebug console tells me when I click on the div:
POST http://admin/Default.aspx GetDate 404 Not Found -18ms
Edit: Note: test.aspx/GetDate must match your aspx page name and function name!
View 1 Replies
Feb 13, 2010
An external server sends incoming SMS messages converted to HTTP requests into my sometimes very time-consuming .aspx page. If no response is returned to the external server in 20 seconds, this is considered as an timeout and the same message is sent to my aspx page again (and maybe again....The optimal solution for me would be that the aspx page reads the incoming message (as an HTTP request to the aspx page), starts the processing of the message in another thread, and immediately renders response back to the external server. The external server has no interest in other stuff than the HTTP status (normally 200). When the processing of the message is completed this results in an entry into the log file of the application.
View 2 Replies
Apr 4, 2011
I am fairly new to MVC and just trying to achieve something which I think shouldn't be too complicated to achieve. Just want to know what the best approach for that is. I have an Event-RSVP application (NerdDinner kind) where you go to view details of the event and then click on an AJAX link that will RSVP you for the event.
<%
if (Model.HasRSVP(Context.User.Identity.Name))
{
%>
<p>
You are registered for this event!
<%:
Ajax.ActionLink("Click here if you can't make it!", "CancelRegistration", "RSVP", new { id = Model.RSVPs.FirstOrDefault(r => r.AttendeeName.ToLower() == User.Identity.Name.ToLower()).RSVPID }, new AjaxOptions { UpdateTargetId = "QuickRegister"})
%>
</p>
<%
}
else
{
%>
<p>................
View 2 Replies
Jul 19, 2010
I am coding a classic .asmx web service. The method get data (as a string) from a server, then assign data to an object, then return that object. But I want to cache that object to a XML file for other request. It's because the data from server is not frequently change. Thus, after some minutes, I have to refresh the XML file. When I refresh XML file, I could write object to XML first, then return that object, but that approach maybe slowly.
How can I return the object for client first, then write this to XML file?
View 5 Replies
Jul 9, 2010
VWD 2008 Express. Visual Basic.
I am using the Directory.GetFiles method as follows:
[Code]....
As expected, it returns files with the ".pdf" extension. I would like to be able to specify more than one extension (like "*.doc*" and "*.txt*", etc.). How can I use GetFiles to return files with more than one desired extension, without returning all files?
View 2 Replies
Oct 13, 2010
I have two methods that do the similar thing. There are small differences here and there, which I can control by passing arguments to them when I call them, so I can effectively merge them. However one returns a string, and the other one an ArrayList. On the top of my head, I could merge them and return an Object, and then get the information I need. Is there a way though to return multiple types in the method's signature? What's the proper way to implement this?
View 5 Replies
Jan 16, 2011
I am wondering if jsonResult method can be used to return Data Table? If so, is it a json array or a json string?
View 6 Replies
Jul 14, 2010
When I do window.open(url), I have to manually replace a value inside that url that contains '&' by '%26'. I am wondering whether there is a function on ASPNET side that I can manipulate that param value that contains '&' to containing '%26' without doing in javascript window.open(). URLEncode does not work nor URLPathEncode!
View 3 Replies
Mar 25, 2010
i have a very big problem: i've created a new test html helper:
[Code]....
i can call it but the first param that i need to pass is htmlHelper and not text as i should do. Why?
View 9 Replies