Esempio n. 1
0
        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 (var composite = new CompositeXmlStream(new System.IO.Stream[] { mock1.Object, mock2.Object, mock3.Object }))
            {
                var buffer = new byte[10];
                composite.Read(buffer, 0, buffer.Length);
            }

            mock1.Verify(s => s.Close());
            mock2.Verify(s => s.Close());
            mock3.Verify(s => s.Close());
        }
Esempio n. 2
0
        public void AlwaysExhaustAggregatedStreams()
        {
            const string expected = "<agg:Root xmlns:agg=\"http://schemas.microsoft.com/BizTalk/2003/aggschema\">" +
                                    "<agg:InputMessagePart_0><part-one xmlns=\"part-one\"><child-one>one</child-one></part-one></agg:InputMessagePart_0>" +
                                    "<agg:InputMessagePart_1><part-two xmlns=\"part-two\"><child-two>two</child-two></part-two></agg:InputMessagePart_1>" +
                                    "</agg:Root>";

            using (var composite = new CompositeXmlStream(new System.IO.Stream[] { new MemoryStream(_part1), new MemoryStream(_part2) }))
            {
                var buffer = new byte[Encoding.UTF8.GetByteCount(expected)];
                var offset = 0;
                int bytesRead;
                while ((bytesRead = composite.Read(buffer, offset, 8)) > 0)
                {
                    offset += bytesRead;
                }
                var actual = Encoding.UTF8.GetString(buffer);
                actual.Should().Be(expected);
            }
        }