public IEnumerable<ISourcedEvent> GetAllEvents(Guid id) { var sourcePath = string.Format("{0}{1}{2}", BasePath, Path.DirectorySeparatorChar, id); var tapeStream = new FileTapeStream.FileTapeStream(sourcePath); var records = tapeStream.ReadRecords(); List<ISourcedEvent> events = records.Select(rec => Streamer.DeserializeEvent(rec.Data)).ToList(); // todo: Add caching return events.OrderBy(n => n.EventTimeStamp); }
public IEnumerable <ISourcedEvent> GetAllEvents(Guid id) { var sourcePath = string.Format("{0}{1}{2}", BasePath, Path.DirectorySeparatorChar, id); var tapeStream = new FileTapeStream.FileTapeStream(sourcePath); var records = tapeStream.ReadRecords(); List <ISourcedEvent> events = records.Select(rec => Streamer.DeserializeEvent(rec.Data)).ToList(); // todo: Add caching return(events.OrderBy(n => n.EventTimeStamp)); }
public void AppendAndReadRecordsTest() { var target = new FileTapeStream.FileTapeStream("test", new FakeTapeStreamSerializer()); const string expected = "Some test data"; target.Append(Encoding.ASCII.GetBytes(expected)); IEnumerable <TapeRecord> records = target.ReadRecords(); var items = new List <TapeRecord>(records); var actual = Encoding.ASCII.GetString(items[0].Data); Assert.AreEqual(expected, actual); }
public void AppendAndReadRecordsTest() { var target = new FileTapeStream.FileTapeStream("test", new FakeTapeStreamSerializer()); const string expected = "Some test data"; target.Append(Encoding.ASCII.GetBytes(expected)); IEnumerable<TapeRecord> records = target.ReadRecords(); var items = new List<TapeRecord>(records); var actual = Encoding.ASCII.GetString(items[0].Data); Assert.AreEqual(expected, actual); }