public void ChangeExtension() { Assert.Equal("test.one", LinuxPath.ChangeExtension("test", "one")); Assert.Equal("test.one", LinuxPath.ChangeExtension("test.zero", "one")); Assert.Equal("/foo/test.one", LinuxPath.ChangeExtension("\\foo\\test", "one")); Assert.Equal("/foo/test.one", LinuxPath.ChangeExtension("\\foo\\test.zero", "one")); }
public void ChangeExtensionTest() { String result = LinuxPath.ChangeExtension("/system/busybox", "foo"); Assert.AreEqual <string>("/system/busybox.foo", result); result = LinuxPath.ChangeExtension("/system/xbin/file.ext", "myext"); Assert.AreEqual <string>("/system/xbin/file.myext", result); result = LinuxPath.ChangeExtension("/system/xbin/file.ext", ""); Assert.AreEqual <string>("/system/xbin/file", result); result = LinuxPath.ChangeExtension("/system/busybox.foo", ""); Assert.AreEqual <string>("/system/busybox", result); }
public void WhenPathContainsInvalidCharacter_ShouldThrowArgumentException( ) { int errorCount = 0; for (var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x) { try { string result = LinuxPath.ChangeExtension("/my-invalid-path/f-{0}".With(LinuxPathConsts.InvalidPathChars[x]), "ext"); } catch (ArgumentException) { errorCount++; } } Assert.Equal(LinuxPathConsts.InvalidPathChars.Length, errorCount); }
public void WhenPathHasNoExtension_ShouldReturnPathWithExtension( ) { string result = LinuxPath.ChangeExtension("/my-path/to/file", ".ext2"); Assert.Equal("/my-path/to/file.ext2", result); }
public void WhenExtensionStartsWithDot_ShouldReturnChangedExtension( ) { string result = LinuxPath.ChangeExtension("/my-path/to/file.ext1", ".ext2"); Assert.Equal("/my-path/to/file.ext2", result); }
public void WhenExtensionIsEmpty_ShouldReturnPath( ) { string result = LinuxPath.ChangeExtension("/my-path/to/file.ext1", string.Empty); Assert.Equal("/my-path/to/file.ext1", result); }
public void WhenPathLengthIsZero_ShouldReturnEmpty() { string result = LinuxPath.ChangeExtension(string.Empty, "ext"); Assert.Equal(string.Empty, result); }
public void WhenPathIsNull_ShouldReturnNull() { string result = LinuxPath.ChangeExtension(null, "ext"); Assert.Null(result); }