public void AggregatesIndividualStreamsOfDifferentEncodings() { using (var part1 = new MemoryStream(_part1)) using (var part2 = new MemoryStream(_part2)) using (var part3 = new MemoryStream(_part3)) using (var composite = CompositeXmlReader.Create(new[] { part1, part2, part3 })) { composite.Read(); composite.ReadOuterXml().Should().Be(EXPECTED); } }
public void SupportsXslTransformOfAggregatedXmlReaders() { using (var part1 = new StringStream(PART_1)) using (var part2 = new StringStream(PART_2)) using (var part3 = new StringStream(PART_3)) using (var composite = CompositeXmlReader.Create(new[] { XmlReader.Create(part1), XmlReader.Create(part2), XmlReader.Create(part3) })) { var xslTransformDescriptor = new XslCompiledTransformDescriptor(new XslCompiledTransformDescriptorBuilder(typeof(IdentityTransform))); var builder = new StringBuilder(); using (var writer = XmlWriter.Create(builder)) { xslTransformDescriptor.XslCompiledTransform.Transform(composite, xslTransformDescriptor.Arguments, writer !); } builder.GetReaderAtContent().ReadOuterXml().Should().Be(EXPECTED); } }
public void AggregatesUninitializedXmlReaders() { var part1 = XmlReader.Create(new StringReader(PART_1), new XmlReaderSettings { CloseInput = true }); var part2 = XmlReader.Create(new StringReader(PART_2), new XmlReaderSettings { CloseInput = true }); var part3 = XmlReader.Create(new StringReader(PART_3), new XmlReaderSettings { CloseInput = true }); using (var composite = CompositeXmlReader.Create(new[] { part1, part2, part3 })) { composite.MoveToContent(); composite.ReadOuterXml().Should().Be(EXPECTED); } }
public void AggregatesUninitiatedXmlReaders() { var part1 = XmlReader.Create(new StringReader(PART_1), new XmlReaderSettings { CloseInput = true }); var part2 = XmlReader.Create(new StringReader(PART_2), new XmlReaderSettings { CloseInput = true }); var part3 = XmlReader.Create(new StringReader(PART_3), new XmlReaderSettings { CloseInput = true }); using (var composite = CompositeXmlReader.Create(new[] { part1, part2, part3 })) { composite.MoveToContent(); Assert.That(composite.ReadOuterXml(), Is.EqualTo(EXPECTED)); } }
public void SupportsXslTransformOfAggregatedXmlReaders() { var part1 = new StringStream(_xslPart1); var part2 = new StringStream(_xslPart2); var builder = new StringBuilder(); using (var sut = CompositeXmlReader.Create(new[] { XmlReader.Create(part1), XmlReader.Create(part2) })) using (var writer = XmlWriter.Create(builder)) { _xslTransformDescriptor.XslCompiledTransform.Transform(sut, _xslTransformDescriptor.Arguments, writer); } var xdoc = new XmlDocument(); xdoc.Load(builder.GetReaderAtContent()); Assert.That(xdoc.SelectSingleNode("/*").IfNotNull(n => n.LocalName), Is.EqualTo("Envelope")); Assert.That(xdoc.SelectNodes("/env:Envelope/tns:ReleaseBatch", _xslNamespaceManager).IfNotNull(n => n.Count), Is.EqualTo(3)); }
public void CompoundXmlReadersShareXmlNameTable() { var part1 = XmlReader.Create(new StringReader(PART_1), new XmlReaderSettings { CloseInput = true }); var part2 = XmlReader.Create(new StringReader(PART_2), new XmlReaderSettings { CloseInput = true }); var part3 = XmlReader.Create(new StringReader(PART_3), new XmlReaderSettings { CloseInput = true }); using (var composite = CompositeXmlReader.Create(new[] { part1, part2, part3 })) { var outlineReader = (XmlReader)Reflector.GetField(composite, "_outlineReader"); Assert.That(outlineReader.NameTable, Is.SameAs(composite.NameTable)); var readers = (XmlReader[])Reflector.GetField(composite, "_readers"); Assert.That(readers.Select(r => r.NameTable), Is.All.SameAs(composite.NameTable)); } }
public void CompoundXmlReadersShareXmlNameTable() { var part1 = XmlReader.Create(new StringReader(PART_1), new XmlReaderSettings { CloseInput = true }); var part2 = XmlReader.Create(new StringReader(PART_2), new XmlReaderSettings { CloseInput = true }); var part3 = XmlReader.Create(new StringReader(PART_3), new XmlReaderSettings { CloseInput = true }); using (var composite = CompositeXmlReader.Create(new[] { part1, part2, part3 })) { var outlineReader = (XmlReader)Reflector.GetField(composite, "_outlineReader"); outlineReader.NameTable.Should().BeSameAs(composite.NameTable); var readers = (XmlReader[])Reflector.GetField(composite, "_readers"); readers.ForEach(r => r.NameTable.Should().BeSameAs(composite.NameTable)); // TODO create XUnit custom constraint for readers.Select(r => r.NameTable).Should().AllBeSameAs(composite.NameTable); } }
public void InputStreamsAreClosed() { var mock1 = new Mock <MemoryStream>(MockBehavior.Default, _part1) { CallBase = true }; var mock2 = new Mock <MemoryStream>(MockBehavior.Default, _part2) { CallBase = true }; var mock3 = new Mock <MemoryStream>(MockBehavior.Default, _part3) { CallBase = true }; using (CompositeXmlReader.Create(new[] { mock1.Object, mock2.Object, mock3.Object }, new XmlReaderSettings { CloseInput = true })) { } mock1.Verify(s => s.Close()); mock2.Verify(s => s.Close()); mock3.Verify(s => s.Close()); }