예제 #1
0
 private static IList<Record> LoadRecords(string fileContent)
 {
     const string filepath = "filepath";
     var mocks = new MockRepository(MockBehavior.Strict);
     Mock<IFileSystem> fileSystemMock = mocks.Create<IFileSystem>();
     fileSystemMock.Setup(it => it.OpenFileForRead(filepath))
         .Returns(new MemoryStream(Encoding.ASCII.GetBytes(fileContent)));
     IFileSystem fileSystem = fileSystemMock.Object;
     var reader = new CsvFileReader(fileSystem);
     reader.Open(filepath);
     IList<Record> records = new List<Record>();
     while (reader.MoveNext()) {
         records.Add(reader.CurrentRecord);
     }
     return records;
 }