Problem with reflection in Unit / Integration tests

I dynamically create an instance of the class with reflection, and this works fine, except that when I try to do this with unit testing, I use the MS testing environment.
I get a familiar error: “Could not load the file or assembly“ Assy ”or one of its dependencies. The system cannot find the specified file.“
I copied the dll to the bin \ debug bin of the Unit test project - is this not the right place to put it?

string assyName = "Go.Data.SqlServer";
string typeName = "GoMolaMola.Data.SqlServer.DataProviderFactory";

Assembly assy = Assembly.Load( assyName );
object o = assy.CreateInstance( typeName );

Any ideas? I am new to unit testing and any help would be appreciated.

thanks

+3
source share
3 answers

bin/Debug . Visual Studio unit test TestResults ( , , ) .

, DLL .DLL , DeploymentItem, , .

+4

, :( 1. 2. DeploymentItem 3. Post-Build , Unit test out .... .

, Local Test Setting → Deployment

+1

, DLL Unit Testing, post-build, DLL . , . , : (

Post-Build, , , , Post-Build :

copy $(TargetPath) "$(SolutionDir)yourDir\$(TargetFileName)"
0
source

Source: https://habr.com/ru/post/1712487/


All Articles