MyTested.WebApi icon indicating copy to clipboard operation
MyTested.WebApi copied to clipboard

Make WithResponseTime more fluent

Open ivaylokenov opened this issue 8 years ago • 16 comments

Currently the method can be called only after ShouldReturnHttpResponseMessage

ivaylokenov avatar Dec 02 '15 21:12 ivaylokenov

@ivaylokenov : Thankq , But am trying to use it in my Integration Testing. I get errors. Can we achieve Integration testing from Remote server using this library?.

tdbgautham avatar Dec 04 '15 04:12 tdbgautham

Example: My Web API is running in another server, I need to send request & get response from that server. Does this library supports it ?

tdbgautham avatar Dec 04 '15 04:12 tdbgautham

@tdbgautham Can you please give me the integration test code and the errors you receive and I will take a look and fix it.

ivaylokenov avatar Dec 04 '15 06:12 ivaylokenov

Also how do you start and setup the integration test code?

ivaylokenov avatar Dec 04 '15 06:12 ivaylokenov

@tdbgautham I tested locally and it fails here too because currently the server is started in memory but it will be easy feature to add. Will update the library tomorrow.

ivaylokenov avatar Dec 04 '15 06:12 ivaylokenov

@ivaylokenov Yes, i need to know . How to Start & Setup too . I used Global Configuration. If there is a sample webapi project & respective test case for that webapi will helpful. I have concerns on these -> How to start a Remote server, is there a sample ? -> What is Working(StartUp) ?

I cannot share my code has it owned by company. :( .

tdbgautham avatar Dec 04 '15 06:12 tdbgautham

Most probably you are starting local server with your configuration. There is sample integration testing here, but the server is local: https://github.com/ivaylokenov/MyTested.WebApi/blob/master/samples/Source%20Control%20System%20API/Tests/SourceControlSystem.Api.Tests/IntegrationTests/CommitsIntegrationTests.cs

Will add remote server testing by providing only the base URL address. Should that be ok?

ivaylokenov avatar Dec 04 '15 07:12 ivaylokenov

Yes.That will be helpful. An test case which connects to remote server and does api call and fr that what will be Response time.

-----Original Message----- From: "Ivaylo Kenov" [email protected] Sent: ‎04-‎12-‎2015 12:38 To: "ivaylokenov/MyTested.WebApi" [email protected] Cc: "tdbgautham" [email protected] Subject: Re: [MyTested.WebApi] Make WithResponseTime more fluent (#230)

Most probably you are starting local server with your configuration. There is sample integration testing here, but the server is local: https://github.com/ivaylokenov/MyTested.WebApi/blob/master/samples/Source%20Control%20System%20API/Tests/SourceControlSystem.Api.Tests/IntegrationTests/CommitsIntegrationTests.cs Will add remote server testing by providing only the base URL address. Should that be ok? — Reply to this email directly or view it on GitHub.

tdbgautham avatar Dec 04 '15 17:12 tdbgautham

@tdbgautham Implemented in version 1.1.8. You can update your package. More information here: https://github.com/ivaylokenov/MyTested.WebApi/tree/master/documentation#remote-server

ivaylokenov avatar Dec 05 '15 12:12 ivaylokenov

@ivaylokenov I am able to connect Remotely. But i am not able to provide handler to the remotely accessible server. Included changes for Handler for remoter server. Its working now. Thank you.

tdbgautham avatar Dec 06 '15 12:12 tdbgautham

@ivaylokenov I have one concern on Dispose,. When we do Integration testing, we call many API based on scenario. When i tried that way, it disposes MyWebApi class for single API call. So again i need to do Set-Up. Why can't we dispose this link in server().STOP() . ?

tdbgautham avatar Dec 11 '15 06:12 tdbgautham

@tdbgautham You should do it the following way:

// first run this
MyWebApi.Server().IsLocatedAt("http://myremoteurl.com");

// then how many you want of these
MyWebApi
    .Server()
    .WorkingRemotely() // working remotely will use the globally set base address
    .WithHttpRequestMessage(req => req.WithMethod(HttpMethod.Get))
    .ShouldReturnHttpResponseMessage()
    .WithStatusCode(HttpStatusCode.OK);

Any problems with that? What is your setup code? Can you give a sample or your usage?

ivaylokenov avatar Dec 11 '15 06:12 ivaylokenov

@ivaylokenov tried as mentioned above, but i need to set Handler in Remote server for my request. I tried to set as GlobalClient in your library by including handler, but its getting disposed.

MyWebApi.Server().IsLocatedAt("http://localhost/", handler);

Tried this way. I am able to get Handler for 1st request, but second request again i need to set the handler. I dont know why.

tdbgautham avatar Dec 16 '15 04:12 tdbgautham

@tdbgautham Will take a look. Can you give some sort of code sample what are you trying to do because I am kind of guessing your problem?

ivaylokenov avatar Dec 16 '15 06:12 ivaylokenov

@ivaylokenov Ok. How can we set global handler for remote server integration testing ?

tdbgautham avatar Dec 18 '15 04:12 tdbgautham

@tdbgautham Ususally you do not need to set the handler. Can you write a small code sample and add it to pastebin so that I can see what you are trying to accomplish and guide you to a solution?

ivaylokenov avatar Dec 18 '15 11:12 ivaylokenov