public void BrokenEventsDoNotStopReaderAndAreReported() { var zip = Path.Combine(RawDir, "a.zip"); using (var wa = new WritingArchive(zip)) { wa.Add(new CommandEvent { IDESessionUUID = "s1" }); wa.AddAsPlainText("xxx"); wa.Add(new CommandEvent { IDESessionUUID = "s2" }); wa.AddAsPlainText("xxx"); wa.Add(new CommandEvent { IDESessionUUID = "s3" }); } AssertIds("sid:s1", "sid:s2", "sid:s3"); Mock.Get(_log).Verify( l => l.DeserializationError(zip, "1.json", It.IsAny <JsonReaderException>()), Times.Once); Mock.Get(_log).Verify( l => l.DeserializationError(zip, "3.json", It.IsAny <JsonReaderException>()), Times.Once); }
public void SetUp() { _zip = Path.Combine(DirTestRoot, "a.zip"); using (var wa = new WritingArchive(_zip)) { wa.Add(Event(1)); wa.AddAsPlainText("xxx"); wa.Add(Event(2)); } }
public void LastRead() { using (var wa = new WritingArchive(_zipPath)) { wa.AddAsPlainText("x"); wa.AddAsPlainText("y"); wa.AddAsPlainText("z"); } using (var ra = new ReadingArchive(_zipPath)) { Assert.Null(ra.CurrentInternalFileName); ra.GetNextAsPlainText(); Assert.AreEqual("0.json", ra.CurrentInternalFileName); ra.GetNextAsPlainText(); Assert.AreEqual("1.json", ra.CurrentInternalFileName); ra.GetNextAsPlainText(); Assert.AreEqual("2.json", ra.CurrentInternalFileName); } }
public void ReadAsPlainText() { using (var wa = new WritingArchive(_zipPath)) { wa.AddAsPlainText("x"); wa.AddAsPlainText("y"); wa.AddAsPlainText("z"); } var actuals = new List <string>(); using (var ra = new ReadingArchive(_zipPath)) { while (ra.HasNext()) { actuals.Add(ra.GetNextAsPlainText()); } } var expecteds = new[] { "x", "y", "z" }; CollectionAssert.AreEqual(expecteds, actuals); }
public void DeserializationIssuesNoNotCrashTheCleanerAndAreReported() { var zip = Path.Combine(MergedDir, "a.zip"); using (var wa = new WritingArchive(zip)) { wa.Add(E("a", 10)); wa.AddAsPlainText("xxx"); wa.Add(E("a", 20)); wa.AddAsPlainText("yyy"); wa.Add(E("a", 30)); } Clean("a.zip"); AssertEvents("a.zip", E("a", 10), E("a", 20), E("a", 30)); Mock.Get(_log).Verify( l => l.DeserializationError(zip, "1.json", It.IsAny <JsonReaderException>()), Times.Once); Mock.Get(_log).Verify( l => l.DeserializationError(zip, "3.json", It.IsAny <JsonReaderException>()), Times.Once); }
public void BrokenEventsDoNotStopMergingAndAreReported() { Add(@"a.zip", Event("a")); var zip = Path.Combine(RawDir, "b.zip"); using (var wa = new WritingArchive(zip)) { wa.Add(Event("b1")); wa.AddAsPlainText("xxx"); wa.Add(Event("b2")); wa.AddAsPlainText("xxx"); wa.Add(Event("b3")); } Merge(@"a.zip", @"b.zip"); Expect(@"a.zip", Event("a"), Event("b1"), Event("b2"), Event("b3")); Mock.Get(_log).Verify( l => l.DeserializationError(zip, "1.json", It.IsAny <JsonReaderException>()), Times.Once); Mock.Get(_log).Verify( l => l.DeserializationError(zip, "3.json", It.IsAny <JsonReaderException>()), Times.Once); }