mercredi 1 avril 2015

C# unit test environment different from Application

I have a class that I'll describe as a "black box". Among another things, it makes a TCP/IP connection to a server. I do not have the source code to this black box.


The class works fine when it is used from within a console or gui application. The class does not function when it is used inside of a Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod. (It throws an unhelpful "unknown error" exception.)


What is the nature of Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod and why does it not give a class the "same environment" as an application? What about the "environment" is different? Perhaps some static initialization is not performed. Perhaps some "singletons" are not initialized. Perhaps there is no "Main" at the top of the call stack and my black box can reflect on that?


Aucun commentaire:

Enregistrer un commentaire