Path Constraints
"Charlie Poole" <[email protected]>
| Newsgroups | gmane.comp.windows.dotnet.nunit.devel |
|---|---|
| Message-ID | <004501c8824d$1d16b820$6401a8c0@ferrari> |
Hi All,
We had a lot of discussion on Pat-related asserts, with Daniel providing
some new info I wasn't aware of. In light of all that, I backed away
from using any OS designation to modify the path constraints, which
I just checked in.
If you are only working with a single OS Platform, the constraints
"just work" ...
Constructors:
SamePathConstraint( "/some/path" );
SamePathOrUnderConstraint( "C:\\some\\path" );
Helpers:
Is.SamePath( "C:\\some\path" );
Is.SamePathOrUnder( "/some/path" );
If you need to work with paths for other platforms than the one you are
running the tests on - that is you are doing a serious cross-platform
application - then you probably have some library you wrote to manage
paths. Use that. :-)
But for very simple things, you can use the IgnoreCase and the new
RespectCase modifiers to ensure that you get the semantics expected
on the target OS and that your tests will work the same wherever they
are run.
Confused? Here's an example...
Assert.That( "D:\\My\\Path\\On\\Windows,
Is.SamePathOrUnder( "D:\\MY\\PATH" ).IgnoreCase
This will work correctly even when the Assert is executed on a Linux
system, since we are telling it to ignore case.
Some time in the future, I'd like to write a general path manipulation
library similar to Perl's Path::Class, but until then, this will do.
Charlie
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/