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

Directory IO bug for Test when enumerating files #1298

Open
janigbg opened this issue Feb 9, 2024 · 0 comments
Open

Directory IO bug for Test when enumerating files #1298

janigbg opened this issue Feb 9, 2024 · 0 comments

Comments

@janigbg
Copy link

janigbg commented Feb 9, 2024

When enumerating files, the files should be returned in a sequence using full path and file name.
For the Test implementation, it seems to return each file as two entries; one with filename only, and one with last directory and filename.

Source in Microsoft docs:
https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.enumeratefiles?view=net-7.0#system-io-directory-enumeratefiles(system-string-system-string)

Repro:

var path = "c:\\dir\\subdir";
var expected = Path.Combine(path, "file");
var computation =
    from dir in Directory<Runtime>.create(path)
    from file in File<Runtime>.writeAllText(expected, string.Empty)
    from files in Directory<Runtime>.enumerateFiles(path)
    select files;

var actual = (await computation.Run(Runtime.New()))
    .ThrowIfFail();

Assert.That(actual, Is.EquivalentTo(Seq1(expected)));

I get this result:

Assert.That(actual, Is.EquivalentTo(Seq1(expected)))
  Expected: equivalent to < "c:\dir\subdir\file" >
  But was:  < "subdir\file", "file" >
  Missing (1): < "c:\dir\subdir\file" >
  Extra (2): < "file", "subdir\file" >
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