public void ReadFileDoesNotExistAndTestIfExists() { CreateTemporaryFile((fileName) => { // Make sure the file does not exist. File.Delete(fileName); OpenReadStreamFromFile streamFromFile = new OpenReadStreamFromFile() { Name = "Reader", FilePath = CreateParameter(fileName, "FileName"), CheckFileExistsAtRunStart = CreateParameter(true, "Check") }; string error = null; Assert.IsFalse(streamFromFile.RuntimeValidation(ref error)); Assert.IsNotNull(error, "There was no error message!"); // make sure that we can read the file Assert.IsFalse(NoExecutionErrors(() => { using (var reader = streamFromFile.Invoke()) { } }, out var _), "There was no error when reading a file that does not exist!"); }); }
public void ReadFileExistsAndDontTestIfExists() { CreateTemporaryFile((fileName) => { OpenReadStreamFromFile streamFromFile = new OpenReadStreamFromFile() { Name = "Reader", FilePath = CreateParameter(fileName, "FileName"), CheckFileExistsAtRunStart = CreateParameter(false, "Check") }; string error = null; Assert.IsTrue(streamFromFile.RuntimeValidation(ref error)); Assert.IsNull(error); // make sure that we can read the file Assert.IsTrue(NoExecutionErrors(() => { using (var reader = streamFromFile.Invoke()) { } }, out var e), e?.Message); }); }