public void OpenFile_Write_WriteLines_NotWrite() { ExceptionCatcher exc = new ExceptionCatcher(); exc.expectedMessage = "Wrong access mode."; exc.test(() => { fh = new FileHandler(file_1); fh.WriteLines(File1ContentRaw); } ); }
public void OpenFile_Read_ReadLines_NotRead() { ExceptionCatcher exc = new ExceptionCatcher(); exc.expectedMessage = "Wrong access mode."; exc.test(() => { fh = new FileHandler(file_notExist_3, true); fh.ReadLines(); } ); }
public void OpenFile_Read_NotExist() { ExceptionCatcher exc = new ExceptionCatcher(); string fullPath = Path.Combine(localFolder, file_notExist_1); exc.expectedMessage = String.Format("File: \"{0}\" doesn't exist.", fullPath); exc.test(() => { fh = new FileHandler(file_notExist_1); } ); }
public void OpenFile_Write_WriteLines_NotReady() { ExceptionCatcher exc = new ExceptionCatcher(); exc.expectedMessage = "Not initialized."; enforceClose = true; exc.test(() => { fh = new FileHandler(file_notExist_4, true); fh.isReady = false; fh.WriteLines(File1ContentRaw); } ); }
public void OpenFile_Read_CloseStream_NotReady() { ExceptionCatcher exc = new ExceptionCatcher(); exc.expectedMessage = "Not initialized."; exc.test(() => { fh = new FileHandler(file_1); fh.isReady = false; fh.CloseStream(); } ); // cleanup - allow to close stream fh.isReady = true; fh.CloseStream(); }
public void OpenFile_Write_WriteLines_FileReadOnly() { if (!File.GetAttributes(file_3).HasFlag(FileAttributes.ReadOnly)) { File.SetAttributes(file_3, FileAttributes.ReadOnly); } ExceptionCatcher exc = new ExceptionCatcher(); exc.expectedMessage = "File is read-only. Cannot open for write."; exc.test(() => { fh = new FileHandler(file_3, true); } ); // cleanup the RO flag if (File.GetAttributes(file_3).HasFlag(FileAttributes.ReadOnly)) { File.SetAttributes(file_3, File.GetAttributes(file_3) & ~FileAttributes.ReadOnly); } }