Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9283169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:33:44+00:00 2026-06-18T18:33:44+00:00

Using servicestack, there are examples of unit testing using types, etc. Here is an

  • 0

Using servicestack, there are examples of unit testing using types, etc. Here is an example:
GetFactorial

I would like to test my REST style service with a test similar to the above.

Here is an example REST unit test FileService

Notice how in the PUT unit test, the Path argument has to be specified in the URL text instead of in the class argument. Another example is here, where we have perfectly good request models that have to be translated into the URL. For testing, I would like to get away from having to build the arguments in the url and use a system similar to the one above like this:

var response = restClient.Put<FilesResponse>(new Files { TextContents = ReplacedFileContents, Path = "README.txt" });

or

var singleCustomer = restClient.Get<Customer>(new Customer {Id=1};

Is this possible?

Then there is the DirectServiceClient. Would that help? In the end, with servicestack, we get to write services and they can be called from many different type clients – I would like to write my unit test like that.

Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:33:46+00:00Added an answer on June 18, 2026 at 6:33 pm

    If you decorate your DTOs with the route variable and use ServiceStack’s “New API” then it can discover the routes automatically. You can get away with writing very minimal code and still get a strong typed rest API.

    Your code could look something like this:

    Customer singleCustomer = restClient.Get(new Customer {Id=1});
    

    See https://github.com/ServiceStack/ServiceStack/wiki/New-Api

    In response to your comments, your DTO needs to adhere to the IReturn interface:

    [Route("/customer/{Id}")]
    public Customer : IReturn<Customer> {
       public int Id {get;set;}
    }
    

    The IRestClient interface below will now be able to work with your DTO without specify the type since it is expecting an IReturn object.

    public interface IRestClient 
    {
       TResponse Get<TResponse>(IReturn<TResponse> request);
       ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to authenticate users of my servicestack.net rest services using basic auth
AuthorizeAttribute is useless while using ServiceStack.Mvc AuthenticateAttribute is for DTO objects. There is no
I'm using ServiceStack RedisClient for caching. How can I set a timeout? For example
have created REST service using servicestack and in post request I have return object
I have constructed a simple Rest service using ServiceStack (which is brilliant), that returns
When using ServiceStack to create a REST service, how do you handle arbitrary HTTP
I'm creating a rest webservice using the c# framework 'servicestack' (http://www.servicestack.net/) and I'm having
I am following this example: Using NHibernate with ServiceStack In the Contacts class library
I am returning HttpResult from one of the rest service methods using servicestack's new
Is there any examples to be found for running a stored procedure on serviceStack

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.