locked
testing a method RRS feed

  • Question

  • I'd like to test a method that performs insert/update/delete operations to the entities.  I read where I can only access these operations through a post.  Might there be some way, something I could set in the web.config, that allows me to test that method by itself?

     

    Wally

     

    Sunday, September 30, 2007 5:38 PM

Answers

  • Hi Wally,

     

    You are referring to an "Astoria Service Operation", correct?  If so, you should be able to write a test client that just invokes the service operation method directly if you don't want to use HTTP in your testing.  That said, Visual Studio contains a localhost only development webserver (which you can invoke) that makes testing over HTTP a bit less overhead than "full" infrastructure.

     

     

    Monday, October 1, 2007 3:45 PM
  • Note that in the current CTP bits service operations can only be invoked through GET, which is deeply wrong for side-effecting operations and we strongly discourage developers from doing this in real applications.

     

    The production bits will of course support GET and POST options for service ops.

     

    So, since current bits only do GET, there isn't much of an issue for the time being. You can do GET and simply list your arguments by name in the query string after the "?".

     

    You do have a point about making it easier to test the method. We are thinking of including a few little tools as examples that can be used for this. There is a small example in the CTP already that's a script that can do a GET from any service and dump the response. It's easy to extend it to POST. Finally, there are several tools out there (e.g. Fiddler) that are great for playing with HTTP endpoints.

     

    Pablo Castro

    Technical Lead

    Microsoft Corporation

    http://blogs.msdn.com/pablo

     

     

    Monday, October 1, 2007 6:24 PM
    Moderator

All replies

  • Hi Wally,

     

    You are referring to an "Astoria Service Operation", correct?  If so, you should be able to write a test client that just invokes the service operation method directly if you don't want to use HTTP in your testing.  That said, Visual Studio contains a localhost only development webserver (which you can invoke) that makes testing over HTTP a bit less overhead than "full" infrastructure.

     

     

    Monday, October 1, 2007 3:45 PM
  • I was hoping that I could flip some setting in a .config file and get the ability to call a change method on the url.

     

    Wally

     

    Monday, October 1, 2007 5:31 PM
  • Note that in the current CTP bits service operations can only be invoked through GET, which is deeply wrong for side-effecting operations and we strongly discourage developers from doing this in real applications.

     

    The production bits will of course support GET and POST options for service ops.

     

    So, since current bits only do GET, there isn't much of an issue for the time being. You can do GET and simply list your arguments by name in the query string after the "?".

     

    You do have a point about making it easier to test the method. We are thinking of including a few little tools as examples that can be used for this. There is a small example in the CTP already that's a script that can do a GET from any service and dump the response. It's easy to extend it to POST. Finally, there are several tools out there (e.g. Fiddler) that are great for playing with HTTP endpoints.

     

    Pablo Castro

    Technical Lead

    Microsoft Corporation

    http://blogs.msdn.com/pablo

     

     

    Monday, October 1, 2007 6:24 PM
    Moderator