public void BatchTrackingContextIsNullIfNotXml()
 {
     using (var stream = new StringStream("invalid xml content").AsMarkable())
     {
         stream.ProbeBatchContent().BatchTrackingContext.Should().BeNull();
     }
 }
        public void BatchDescriptorIsNullIfIncompleteBatchContent()
        {
            const string batchContent = @"<ns:BatchContent xmlns:ns=""urn:schemas.stateless.be:biztalk:batch:2012:12"" />";

            using (var stream = new StringStream(batchContent).AsMarkable())
            {
                stream.ProbeBatchContent().BatchDescriptor.Should().BeNull();
            }
        }
        public void BatchTrackingContextIsEmptyIfIncompleteBatchContent()
        {
            const string batchContent = @"<ns:BatchContent xmlns:ns=""urn:schemas.stateless.be:biztalk:batch:2012:12"" />";

            using (var stream = new StringStream(batchContent).AsMarkable())
            {
                var batchTrackingContext = stream.ProbeBatchContent().BatchTrackingContext;
                batchTrackingContext.ProcessActivityId.Should().BeNull();
                batchTrackingContext.MessagingStepActivityIdList.Should().BeNull();
            }
        }
        public void BatchDescriptorIsNullIfInvalidBatchContent()
        {
            const string batchContent = @"<ns:BatchContent xmlns:ns=""urn:schemas.stateless.be:biztalk:batch:2012:12"">
  <ns:MessagingStepActivityIds />
  <ns:EnvelopeSpecName>Be.Stateless.BizTalk.Schemas.Xml.BatchControl+ReleaseBatches</ns:EnvelopeSpecName>
  <ns:Parts />
</BatchContent>";

            using (var stream = new StringStream(batchContent).AsMarkable())
            {
                stream.ProbeBatchContent().BatchDescriptor.Should().BeNull();
            }
        }
        public void BatchDescriptorHasPartition()
        {
            const string batchContent = @"<ns:BatchContent xmlns:ns=""urn:schemas.stateless.be:biztalk:batch:2012:12"">
  <ns:EnvelopeSpecName>envelope-spec-name</ns:EnvelopeSpecName>
  <ns:Partition>p-one</ns:Partition>
  <ns:MessagingStepActivityIds>013684EE620E4A0BB6D6F7355B26D21B</ns:MessagingStepActivityIds>
  <ns:Parts />
</BatchContent>";

            using (var stream = new StringStream(batchContent).AsMarkable())
            {
                var batchDescriptor = stream.ProbeBatchContent().BatchDescriptor;
                batchDescriptor.EnvelopeSpecName.Should().Be("envelope-spec-name");
                batchDescriptor.Partition.Should().Be("p-one");
            }
        }
        public void BatchTrackingContextOnlyHasProcessActivityId()
        {
            const string batchContent = @"<ns:BatchContent xmlns:ns=""urn:schemas.stateless.be:biztalk:batch:2012:12"">
  <ns:EnvelopeSpecName>Be.Stateless.BizTalk.Schemas.Xml.BatchControl+ReleaseBatches</ns:EnvelopeSpecName>
  <ns:Partition>partition</ns:Partition>
  <ns:ProcessActivityId>A800441B209E46A087A16833661590C2</ns:ProcessActivityId>
  <ns:Parts />
</BatchContent>";

            using (var stream = new StringStream(batchContent).AsMarkable())
            {
                var batchTrackingContext = stream.ProbeBatchContent().BatchTrackingContext;
                batchTrackingContext.ProcessActivityId.Should().Be("A800441B209E46A087A16833661590C2");
                batchTrackingContext.MessagingStepActivityIdList.Should().BeNull();
            }
        }
        public void BatchTrackingContextOnlyHasMessagingStepActivityIds()
        {
            const string batchContent = @"<ns:BatchContent xmlns:ns=""urn:schemas.stateless.be:biztalk:batch:2012:12"">
  <ns:EnvelopeSpecName>Be.Stateless.BizTalk.Schemas.Xml.BatchControl+ReleaseBatches</ns:EnvelopeSpecName>
  <ns:MessagingStepActivityIds>013684EE620E4A0BB6D6F7355B26D21B,08FCB363E00F4BD78D15D8EB2E80B411,0B12CC6AE51740F6ABF672E3B32B496D</ns:MessagingStepActivityIds>
  <ns:Parts />
</BatchContent>";

            using (var stream = new StringStream(batchContent).AsMarkable())
            {
                var batchTrackingContext = stream.ProbeBatchContent().BatchTrackingContext;
                batchTrackingContext.ProcessActivityId.Should().BeNull();
                batchTrackingContext.MessagingStepActivityIdList.Should().BeEquivalentTo(
                    "013684EE620E4A0BB6D6F7355B26D21B",
                    "08FCB363E00F4BD78D15D8EB2E80B411",
                    "0B12CC6AE51740F6ABF672E3B32B496D");
            }
        }