DirectoryAssert fails to recognise the sub folder using IsWithin

Bug #574408 reported by aahkam
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
NUnit Framework
Won't Fix
High
Unassigned
NUnit V2
Fix Released
High
Charlie Poole

Bug Description

Fails to recognize the second path was the direct sub directory.

            var tempPath = Path.GetTempPath();
            var tempPathParent = Path.GetDirectoryName(Path.GetDirectoryName(tempPath));

            DirectoryAssert.AreEqual(new DirectoryInfo(tempPath), new DirectoryInfo(tempPath));

            Assert.That(tempPath, Is.SamePathOrUnder(tempPathParent));

            // bugs??
            DirectoryAssert.IsWithin(tempPathParent, tempPath); // failed the tests

Related branches

Revision history for this message
Charlie Poole (charlie.poole) wrote :

This odd behavior is caused by the fact that GetTempPath() returns a string with a trailing \
while the list of directories to which the comparison is made do not have such a slash.

This will be fixed but DirectoryAssert is likely to be deprecated in favor of the PathConstraints
in the next release.

Changed in nunitv2:
assignee: nobody → Charlie Poole (charlie.poole)
status: New → Fix Committed
importance: Undecided → High
Changed in nunit-3.0:
status: New → Triaged
importance: Undecided → High
Changed in nunitv2:
milestone: none → 2.5.6
Changed in nunitv2:
status: Fix Committed → Fix Released
Revision history for this message
Charlie Poole (charlie.poole) wrote :

DirectoryAssert is being dropped from the 3.0 framework.

Changed in nunit-3.0:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.