using PepLib.IO; using Xunit; namespace PepLib.Core.Tests.IO; public class NestReaderTests { [Fact] public void Read_ReadOnlyFile_DoesNotRequestWriteAccess() { // Arrange: a file on a read-only mount denies write-access opens (EROFS on Linux, // UnauthorizedAccessException on Windows when the read-only attribute is set). // NestReader only ever reads nest files, so it must never request FileAccess.Write. var path = Path.GetTempFileName(); try { File.SetAttributes(path, FileAttributes.ReadOnly); var reader = new NestReader(); // Act / Assert: opening must succeed (i.e. not throw because of the read-only // attribute). Parsing the empty/invalid content is expected to fail separately. var ex = Record.Exception(() => reader.Read(path)); Assert.IsNotType(ex); } finally { File.SetAttributes(path, FileAttributes.Normal); File.Delete(path); } } }