NetTalk Central

Author Topic: Creating a NetWebServerWorker object for unit testing  (Read 3358 times)

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Creating a NetWebServerWorker object for unit testing
« on: October 08, 2015, 05:55:44 PM »
Hi, Bruce

I am trying to add unit testing for the many small app specific procedures/methods of my app.   Many of these procedures receive a NetWebServerWorker as a parameter, mainly to access or set SessionValues.    I would like to instantiate a NetWebServerWorker object independent of an actual connection so I can assign  SessionValues and pass it to the procedure as part of the test.   Is there a way to do that?

Thank you. 

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11247
    • View Profile
Re: Creating a NetWebServerWorker object for unit testing
« Reply #1 on: October 08, 2015, 11:52:16 PM »
Sure, it's just an object.
But all the "global" stuff is done by the WebServer object, so you'll need that as well.

s_web        NetWebServer
p_web        NetWebServerWorker

Then the p_web needs to be set to point at the s_web;
This is usually done by priming a NetWebServerRequestDataType structure, and assigning it to the p_web.RequestData property;

RequestData    Group(NetWebServerRequestDataType).

RequestData.WebServer &= s_web


Obviously the WebHandler is expecting a lot more in the way of data in the structure, so depending on what your methods do you may need to init more properties. but hopefully this will get you started.

cheers
Bruce
« Last Edit: October 12, 2015, 05:41:06 AM by Bruce »

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Creating a NetWebServerWorker object for unit testing
« Reply #2 on: October 09, 2015, 01:07:30 PM »
Excellent.   Thanks, Bruce.