Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some NUnit Tests failed due to current drive of installation - proposed solution enclosed #64

Open
efef77 opened this issue Jun 17, 2017 · 0 comments

Comments

@efef77
Copy link

efef77 commented Jun 17, 2017

Regarding Pri.LongPath AssemblyVersion 2.0.1.0

Failed unit tests running the tests on D: drive instead of C: drive

  • UncDirectoryTests.TestGetDirectoryRoot()
  • UncDirectoryTests.TestGetPathRoot()
  • DirectoryInfoTests.TestMoveToDifferentRoot()
    These test where depending on a certain drive (C:)

I did some work on it:
So I recommend fixed test cases as follows.
They will run on any drive

-------------------------------
public class UncDirectoryTests
-------------------------------
[Test]
public void TestGetDirectoryRoot()
{   
    string plain = Directory.GetDirectoryRoot(directory);
    string unc = Directory.GetDirectoryRoot(uncDirectory);
    string must = @"\\localhost\X$\".Replace('X', plain[0]); // use current drive letter
    Assert.IsTrue(must.Equals(unc, StringComparison.InvariantCultureIgnoreCase));
}

[Test]
public void TestGetPathRoot()
{
    var root = Path.GetPathRoot(uncDirectory);
    Assert.IsNotNull(root);
    Assert.AreEqual(15, root.Length);
    var plain = Path.GetPathRoot(directory);
    string must = @"\\localhost\X$\".Replace('X', plain[0]); // use current drive letter
    Assert.IsTrue(must.Equals(root, StringComparison.InvariantCultureIgnoreCase));
}    
    
-------------------------------
public class DirectoryInfoTests
-------------------------------
[Test]
public void TestMoveToDifferentRoot()
{
    var randomFileName = Path.GetRandomFileName();
    var tempLongPathDirectory = Path.Combine(longPathDirectory, randomFileName);
    var di = new DirectoryInfo(tempLongPathDirectory);

    // get other drive letter
    char letter = longPathDirectory[0];
    if (letter < 'A' || letter >= 'Z') throw new Exception("invalid letter " + letter);
    letter = (char)(letter + 1); // next other drive
    string target = @"" + letter + @":\";
    Assert.Throws<IOException>(() => di.MoveTo(target)); // move to other drive
}

may some one update the test cases?
thx for great work on library

regards efef77

@efef77 efef77 changed the title Some NUnit Tests failed due to current drive of installation Some NUnit Tests failed due to current drive of installation - proposed solution enclosed Jun 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant