Skip to content

Commit 772a5b7

Browse files
acesnikclaude
andcommitted
Cover the two Bruker not-found paths
Both checks changed in this PR are only reachable through BrukerFileReader directly: MsDataFileReader.GetDataFile rejects a missing path itself, so every existing test goes through the factory and neither check runs. That left the DirectoryNotFoundException throw and the analysis.baf FileNotFoundException throw unhit, and the File.Exists branch half-covered. Both tests fail against the pre-PR reader - the first saw FileNotFoundException instead of DirectoryNotFoundException, the second saw a null FileName. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent cd0986a commit 772a5b7

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

mzLib/Test/FileReadingTests/SpectraFileReading/TestBruker.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,5 +392,37 @@ public void TestPrecursorChargeStateIsReadFromPerSpectrumVariables()
392392
Is.EqualTo(3));
393393
dynamicReader.CloseDynamicConnection();
394394
}
395+
396+
// Both not-found paths have to be reached through the reader directly: MsDataFileReader.GetDataFile
397+
// rejects a missing path itself, so going through the factory never runs either check.
398+
[Test]
399+
public void TestLoadAllStaticDataThrowsWhenTheDotDDirectoryIsMissing()
400+
{
401+
string missing = Path.Combine(Path.GetTempPath(), "mzLibBrukerMissing_" + Guid.NewGuid().ToString("N") + ".d");
402+
var reader = new BrukerFileReader(missing);
403+
404+
var exception = Assert.Throws<DirectoryNotFoundException>(() => reader.LoadAllStaticData());
405+
Assert.That(exception.Message, Does.Contain(missing));
406+
}
407+
408+
// A .d directory that exists but has no analysis.baf: the reader has to say which file is missing
409+
// rather than fall through to the native connection with a path it never checked.
410+
[Test]
411+
public void TestInitiateDynamicConnectionThrowsWhenAnalysisBafIsMissing()
412+
{
413+
string emptyDotD = Path.Combine(Path.GetTempPath(), "mzLibBrukerEmpty_" + Guid.NewGuid().ToString("N") + ".d");
414+
Directory.CreateDirectory(emptyDotD);
415+
try
416+
{
417+
var reader = new BrukerFileReader(emptyDotD);
418+
419+
var exception = Assert.Throws<FileNotFoundException>(() => reader.InitiateDynamicConnection());
420+
Assert.That(exception.FileName, Is.EqualTo(Path.Combine(emptyDotD, "analysis.baf")));
421+
}
422+
finally
423+
{
424+
Directory.Delete(emptyDotD, true);
425+
}
426+
}
395427
}
396428
}

0 commit comments

Comments
 (0)