private IEnumerable <IDEEvent> GetEventsFromArchive(string zip) { using (var ra = new FailsafeIDEEventReadingArchive(zip, (f, ex) => _log.DeserializationError(zip, f, ex))) { foreach (var e in ra.ReadAllLazy()) { yield return(e); } } }
private IEnumerable <IDEEvent> ReadEvents(string relZip) { _log.ReadingZip(relZip); var zip = _io.GetFullPath_Merged(relZip); using (var ra = new FailsafeIDEEventReadingArchive(zip, (f, ex) => _log.DeserializationError(zip, f, ex))) { foreach (var e in ra.ReadAllLazy()) { yield return(e); } } }
public void CanReadAllEvents() { var actuals = new List <IDEEvent>(); using (var sut = new FailsafeIDEEventReadingArchive(_zip, (f, ex) => { })) { foreach (var e in sut.ReadAllLazy()) { actuals.Add(e); } } var expecteds = new[] { Event(1), Event(2) }; CollectionAssert.AreEqual(expecteds, actuals); }
public void NoExceptionNoReport() { using (var wa = new WritingArchive(_zip)) { wa.Add(Event(1)); wa.Add(Event(2)); } Exception e = null; using (var sut = new FailsafeIDEEventReadingArchive(_zip, (f, ex) => { e = ex; })) { // ReSharper disable once ReturnValueOfPureMethodIsNotUsed sut.ReadAllLazy().ToList(); } Assert.Null(e); }
public void ReportsException() { string internalFile = null; Exception e = null; using (var sut = new FailsafeIDEEventReadingArchive( _zip, (f, ex) => { internalFile = f; e = ex; })) { // ReSharper disable once ReturnValueOfPureMethodIsNotUsed sut.ReadAllLazy().ToList(); } Assert.AreEqual("1.json", internalFile); Assert.That(e is JsonReaderException); }