Professional OPC
Development Tools

logos

× If you are developing in .NET, but are using the OPC-UA (OPC Unified Architecture), please post in the QuickOPC-UA category instead.

unit tests - nunit (good practice)

More
12 May 2015 19:50 #3133 by support
I have not tested it, but there is also an EasyDAClient object (accessible through Client property) on the DAClientMapper that you may have to Dispose() as well in this case.

The DAClientMApper is not considered an owner of it and therefore does not dispose of it, because its purpose is to allow developers to set a client object from outside, and its usages can be shared. If we have disposed it we could spoil its other intended usage(s).

Best regards

Please Log in or Create an account to join the conversation.

More
12 May 2015 12:29 #3128 by miron
I have created only one object of easy client and mapper in this way:
   Client = new EasyDAClient();
   ClientMapper = new DAClientMapper(Client);

and these two object I am disposing:
        public void Dispose()
        {
            if (ClientMapper != null)
            {               
                ClientMapper.Subscribe(false);
                ClientMapper.Dispose();                
            }
 
            if (Client != null)
            {
                Client.Dispose();
            }
        }

Please Log in or Create an account to join the conversation.

More
12 May 2015 05:07 #3120 by support
I attempted to reproduce the issue but was not successful. After the last Dispose() is completed, all the threads we have created disappear.

But I know you have reported the issue before I have explained how it is supposed to work. Therefore it is possible that in your test, you were calling Dispose() but it was not the last undisposed EasyXXClient object around. Can you please comment on that?

Please Log in or Create an account to join the conversation.

More
10 May 2015 17:15 #3106 by support
The way to stop the engine should be to finalize or Dispose all EasyXXClient-s. Based on your observation with treads in the original posts, I need to verify whether it is truly happening.

Best regards

Please Log in or Create an account to join the conversation.

More
08 May 2015 09:21 #3102 by miron
Ok. Thank you.
Yes, I aware that EasyXXClient is lightway access to OPC.
And internal engine is managed by QuickOPC.

That means question is like:
How to stop internal engine? Or event how to start. (Main mechanism).
Probably engine is starting during first access to OPC.

This control would be necessary not only in unit testing,
but in some application (windows services) which need to reload configuration.

Please Log in or Create an account to join the conversation.

More
07 May 2015 13:37 #3099 by support
I will have a look at it.

Note that the whole architecture is based on a common "engine", shared by the EasyXXClient objects. For this to work, individual EasyXXClient disposals do not mean much. The disposal of the last outstanding EasyXXClient object, however, should release the resources taken so far. This said, I need to reproduce the problem and decide which situation we are dealing with.

Best regards

Please Log in or Create an account to join the conversation.

More
06 May 2015 19:40 #3090 by miron
I have attached picutre with threads before and after calling Dispose().
And I see that nunit need to terminate threads.
I could execute tests step by step but I have problem with executing whole tests at one time.
Attachments:

Please Log in or Create an account to join the conversation.

More
06 May 2015 19:15 #3089 by miron
Good evening,
What is good practice to use QuickOPC in unit tests.
It looks that test with quickOPC ends later (it hungs on some threads maybe).
In unit test I am using EasyClient and also mapping with subscription.

What I should do after executing tests? Disopse is enough?
What about connection opc and threads which was created in background by QuickOPC?

Thank you.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.205 seconds

      

 Recommend this on Google