Skip to content

Path normalization doesn't match standard C#'s functionality #425

@LatteAno

Description

@LatteAno

In the following unit-test, both normal C# methods are consistent with each other, while MockFileSystem's doesn'tL

[TestMethod]
public void TestPathNormalization() {
	var mockFs = new MockFileSystem(new Dictionary<string, MockFileData>());
	var vectors = new [] {
		new {input = @"c:\top\..\most\file", expected = @"c:\most\file"},
		new {input = @"c:\top\..\most\..\dir\file", expected = @"c:\dir\file"},
		new {input = @"\file", expected = @"c:\file"}, // (assuming you're running on c:)
		new {input = @"c:\top\../..\most\file", expected = @"c:\most\file"},
	};
	foreach (var vector in vectors) {
		var path = Path.GetFullPath(vector.input);
		var fileInfo = new FileInfo(vector.input).FullName;
		var mock = mockFs.FileInfo.FromFileName(vector.input).FullName;

		Assert.AreEqual(vector.expected, path, true);
		Assert.AreEqual(vector.expected, fileInfo, true);
		Assert.AreEqual(vector.expected, mock, true);
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: testinghelpersIssues that address the testing helpersstate: ready to pickIssues that are ready for being worked ontype: bugIssues that describe misbehaving functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions