question

Upvotes
Accepted
5 4 4 3

Unit tests using SSL COM .Net Wrappers don't trigger callback functions

We are using legacy SSL COM .NET wrapper classes in our apps and I'm trying to unit test some new functionality. I can test my functionality if I create a new Windows App, set the appropriate callback functions, and call the "start" method on the ssl record. However, if I do the same thing in either a console app or in a Unit test running under Visual Studio Testing framework, I can't get the the ssl libraries to call my callback functions. I believe it has something to do with the Windows message pump and how it executes (or doesn't) in a Console App and in a Visual Studio testing app. Can you point me to some information on how the threading model or the record update model works with the message pump so I can implement my tests correctly? if you have examples of unit tests, better yet.

Thanks,

Vicente.

elektronrefinitiv-realtimetrepeikon-com-api.netssl
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
4.4k 10 6 9

Hi @Vicente_Barreiro

The info of SSL COM thread model is in Chapter 2.5 of developer guide.

Basically, SSL COM uses the Single Threaded Apartment(STA) model of COM.

I am not familiar with Visual Studio Testing Framework, but if you use NUnit you may have to use RequiresSTA attribute.

The SSL COM package also has console app example under "\SSL Developers Kit - COM Edition 1.2\examples\C#\ssltickr"

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
5 4 4 3

Thanks for your answer. I did find the info you suggested in the developer guide. I've been able to create a test program using a console app, and I'm also able to work with the api's in a windows application. Unfortunately, I cannot get the api to work in a testing framework like Visual Studio Testing Framework or NUnit, regardless of whether I use STA or MTA apartments.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@Vicente_Barreiro

If you wish to test the API callback. I would suggest that you should do system test instead.

UnitTest is for testing single method, Having API call the callback function in UnitTest is not a feasible task.

Instead you could just have mock the real feed with a provider app made with API and then connect to that provider in system test.

Agree with you. That's what I've done using a mock Windows app. Thanks

BTW, this should be marked as the correct answer to the original question. Thxs.

Upvotes
5 4 4 3

Agree with you. That's what I've done using a mock Windows app. Thanks.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.