Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

"Directory Not Found" when testing an assembly that relies on content files
Tim Long
#1 Posted : Wednesday, September 28, 2016 9:56:54 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/20/2016(UTC)
Posts: 24
Location: United Kingdom

Thanks: 2 times
Was thanked: 2 time(s) in 2 post(s)
I'm having a problem running tests against a class library that relies on content files that are expected to be in the same location as the class library assembly.

I have the content files (plain text) configured as "Content" and "Copy Always" to the output directory. The files get copied to a subdirectory in the class library's bin/Debug folder during build.

However when NCrunch runs my tests, the class library throws:

Quote:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Tim\AppData\Local\NCrunch\2532\9\TA.ObjectOrientedAstronomy.Specifications\bin\Debug\Vsop87_data\VSOP87B.ear'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)


Sure enough, the entire subdirectory is missing from the workspace (both the bin/Debug and obj/Debug).

Isn't it reasonable to expect content files to be copied to the test workspace?

Note: I've considered making the files embedded resources, but that's ruled out because the data files must be end-user replaceable.

Best regards,
Tim Long

Tim Long
#2 Posted : Wednesday, September 28, 2016 10:13:51 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/20/2016(UTC)
Posts: 24
Location: United Kingdom

Thanks: 2 times
Was thanked: 2 time(s) in 2 post(s)
Wait! Solved it...

The class library was referencing the content as ".\subdirectory\filename" which was a bad assumption. I've replaced that with a location based on Assembly.GetExecutingAssembly().Location and that seems to be working now. False alarm, sorry.

--Tim
1 user thanked Tim Long for this useful post.
Remco on 9/28/2016(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.020 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download