Testing with c# wrapper of custom messaging

hi, first post. We have been asked to port our “black box” integration tests from C# (xunit) to robot framework. I don’t have any python experience, but I gather it could be possible to use python.net so we can build some wrappers around our C# libraries (messaging using non-http TCP and UDP) to do something like:

customMessenger.Init(127.0.0.1)
differentCustomMessenger.Init(127.0.0.2)

myCommand = create a command (a dto of primitive key value pairs)
customMessenger.Send(myCommand)

wait for message on 2nd api
responseDto = differentCustomMessenger.WaitForMessage(30 sec)
check response for validity

Anyone know if we are being sent in the wrong direction? Can I provide any more use cases or answer any questions?

Hi Seth,

Welcome to the community.

I’m no expert in this, but will do my best to help.

Is this a proprietary protocol?

If it’s a standard protocol then there may already be a python library for that protocol which might be an easier route.

If you need to use the application’s C# Libraries, I know it’s possible to get python to load windows dll’s and call the functions within.

If you look at the WMI python module’s code you’ll see

from win32com.client import GetObject, Dispatch
import pywintypes

So I suspect you’ll need to do something like that, but hopefully this module’s code will give you the pointers you need :crossed_fingers:

After that, I’d suggest breaking the problem in 2 parts:

  1. Create a python module that wraps all the functions in the C# Libraries functions
  2. create a robot framework library (python file) that provides keywords that call those functions and provides high level keywords like Send App Message, Receive App Message, Wait For App Message, etc You’ll know better than me what the keywords should be.

I’ve created python robot framework libraries and python modules, so can help with that, but I never needed to load a DLL because I used the WMI library for my python module.

I hope this was helpful,

Dave.

Also this might be helpful:

The highest voted answer that has this looks like it might be helpful

Example for a C# DLL MyDll.dll:

Dave.

thanks Dave.

I will tackle the “python calls C#” and then I may have some questions on building a RF library.

1 Like