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\DataFi les 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.Reflecti on.Assembly.Get ExecutingAssemb ly().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 4466 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\DataFi les 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.Reflecti on.Assembly.Get ExecutingAssemb ly().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\DataFi les 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.Reflecti on.Assembly.Get ExecutingAssemb ly().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 checked into VSS along with all
the associated projects. Many developers need to work on the same solution.
The problem that I am having is getting a...
|
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 with database if it returns right value or not.
To do so, I need to save all inputs and results as development, debugging
goes on..
But, NUnit...
|
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 new connection is
established.
My Server code is :
---------------------------------------------------------------------
|
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 there must be a automated way of doing this - maybe
by using NDoc (although available formats don't seem particilariy
suited)?
Ideally the test...
|
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 seems to be the logical
choice. Although it works well with very simple classes, it seems to
struggle when you are confronted with anything...
| |
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. Hence can someone who has
used them before share his/her experience on them so that I can get a better
idea and make a proper choice ?
Any link or...
|
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. Everything is fine, compiles and the
tests work fine on the basic application. However once I add some linq
things to it, and specifically the...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
| |
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |