コード例 #1
0
 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);
         }
     }
 }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }