public void FlatFileTestRestart() { System.IO.File.Copy("TestData/FlatFile/output/Test.txt", _testpath3, true); IResource fileResource = new FileSystemResource(new FileInfo(_testpath3)); Assert.IsTrue(fileResource.Exists()); var writer = new FlatFileItemWriter <Person> { Resource = new FileSystemResource(_testpath3), LineAggregator = new LineAggregator(), HeaderWriter = new HeaderWriter() }; var reader = new FlatFileItemReader <Person> { Resource = new FileSystemResource(_testpath3), LinesToSkip = 2, LineMapper = new LineMapper() }; var executionContext = new ExecutionContext(); executionContext.PutLong("FlatFileItemWriter.current.count", 133L); // Last position in Test.txt executionContext.PutLong("FlatFileItemWriter.written", 10L); // Record already written in Test.txt writer.Open(executionContext); writer.Write(GetPersons()); writer.Close(); Assert.IsTrue(System.IO.File.Exists(_testpath3)); Assert.IsTrue(new FileInfo(_testpath3).Length > 0); var persons = new List <Person>(); reader.Open(executionContext); Person person; while ((person = reader.Read()) != null) { persons.Add(person); } reader.Close(); Assert.AreEqual(CountObjects + 10, persons.Count); // The final record number must be 20+10. }
public void TestExists2() { var resource = new FileSystemResource(Path.Combine(TestDataDirectory, "NonExistingFile")); Assert.IsFalse(resource.Exists()); }