Hi All,
This is my first post, I've been finding lots of solutions from this forum. Thanks to all who helped (and ones who asked questions).
I have a strange problem. I'm having a console app and one of the classes in this application needs to read a file from file system. The path is one directory below app path. e.g. if application is in C:\MyApp then the file would be in C:\MyApp\DataFiles directory. I used Reflection to get the path for my executable and just appended the subdirectory name to it for getting file.
Code: string sPath = System.Reflection.Assembly.GetExecutingAssembly(). Location;
It works in all cases, but with NUnit, as NUnit makes a Shadow copy of the loaded assembly, my subdirectory cant be located by my function and the test fails.
Everything works with console app running from cmd prompt, but I cant have NUnit test for it.
Can anyone suggest any way to get the path while running NUnit?
I dont want to use hardcoded path in App.config as it'll be changed with each installation.
Pls dont mind my way of putting the query, as this is my first post.
Thanks for responses in advance.
Cheers,
Nik
5 4463 Frinavale 9,735
Recognized Expert Moderator Expert
Hi All,
This is my first post, I've been finding lots of solutions from this forum. Thanks to all who helped (and ones who asked questions).
I have a strange problem. I'm having a console app and one of the classes in this application needs to read a file from file system. The path is one directory below app path. e.g. if application is in C:\MyApp then the file would be in C:\MyApp\DataFiles directory. I used Reflection to get the path for my executable and just appended the subdirectory name to it for getting file.
Code: string sPath = System.Reflection.Assembly.GetExecutingAssembly(). Location;
It works in all cases, but with NUnit, as NUnit makes a Shadow copy of the loaded assembly, my subdirectory cant be located by my function and the test fails.
Everything works with console app running from cmd prompt, but I cant have NUnit test for it.
Can anyone suggest any way to get the path while running NUnit?
I dont want to use hardcoded path in App.config as it'll be changed with each installation.
Pls dont mind my way of putting the query, as this is my first post.
Thanks for responses in advance.
Cheers,
Nik
I remember briefly using NUnit a few years ago. From what I remember you can leave the test data in your assembly and your code will work perfectly fine on any other install.
I guess I don't understand the problem completely.
A normal end user isn't going to run your code through NUnit...
TRScheel 638
Recognized Expert Contributor
Hi All,
This is my first post, I've been finding lots of solutions from this forum. Thanks to all who helped (and ones who asked questions).
I have a strange problem. I'm having a console app and one of the classes in this application needs to read a file from file system. The path is one directory below app path. e.g. if application is in C:\MyApp then the file would be in C:\MyApp\DataFiles directory. I used Reflection to get the path for my executable and just appended the subdirectory name to it for getting file.
Code: string sPath = System.Reflection.Assembly.GetExecutingAssembly(). Location;
It works in all cases, but with NUnit, as NUnit makes a Shadow copy of the loaded assembly, my subdirectory cant be located by my function and the test fails.
Everything works with console app running from cmd prompt, but I cant have NUnit test for it.
Can anyone suggest any way to get the path while running NUnit?
I dont want to use hardcoded path in App.config as it'll be changed with each installation.
Pls dont mind my way of putting the query, as this is my first post.
Thanks for responses in advance.
Cheers,
Nik
-
using system.windows.forms
-
That gives you access to the application class, which has startup path. Use that instead
Should be something like:
Thanks guys.
But, my Application path is changed to some NUnit Chached path and NUnit just copies dependencies (i.e. .config or interop dll ect) to this chache directory. My required files are copied in output directory dur to their set property, but NUnit doesn't understand it.
Anyways, I've moved my file path to App.config and not its absolute path and everythig works fine. :-)
Cheers,
Nik
Frinavale 9,735
Recognized Expert Moderator Expert
Thanks guys.
But, my Application path is changed to some NUnit Chached path and NUnit just copies dependencies (i.e. .config or interop dll ect) to this chache directory. My required files are copied in output directory dur to their set property, but NUnit doesn't understand it.
Anyways, I've moved my file path to App.config and not its absolute path and everythig works fine. :-)
Cheers,
Nik
I'm glad you got it working!
Thanks for sharing your solution :)
-Frinny
I remember briefly using NUnit a few years ago. From what I remember you can leave the test data in your assembly and your code will work perfectly fine on any other install.
I guess I don't understand the problem completely.
A normal end user isn't going to run your code through NUnit...
Hai
I have got the same problem and I found a solution which works. Download nunit 2.4 and in Tools/options disable shadow copy.
If you have found some other way round in older versions without the new release, please let me know.
Thanks
ArunK
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Peter Rilling |
last post by:
My development team is using VS.NET with VSS integration. They are able to
check in and out from within VS.NET. We also use NUnit for testing our
libraries. Currently our entire solution is...
|
by: Sky Kim |
last post by:
Hi, all.
I've know NUnit for a while, now I try to use it.
Most of application I develope is data base driven.
I want to test data layer most with may input and checking the result, then
compare...
|
by: Naveen Mukkelli |
last post by:
Hi all,
How can we use "NUnit" in socket programming.
I mean, I'm writing a server program which accepts
connection requests from the clients. I want to test the
number of clients whenever a...
|
by: geoffblanduk_nospam |
last post by:
I have an NUnit test plan with well over 500 tests.
I now need to produce a test plan document for these tests -
documenting them one by one with Word is a painfull task.
I was thinking that...
|
by: MD |
last post by:
Hello
I work in a .NET environment and I am about to create a development
strategy. As part of this I am looking at implementing a testing tool
to fit in with an iterative approach and NUnit...
| |
by: Parag |
last post by:
Hi,
I am trying to figure out best testing tool for my project. I have
narrowed down my requirements to two tools NUNIT and VSTS unit. But I have
used neither and I have to use only one of them....
|
by: Mark Elliott |
last post by:
Hi All,
I'm just playing with asp.net mvc and link-to-sql for the first time. I'm
using visual web developer 2008. I create the project fine, choose nunit
as my test framework in the wizard. ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |