示例#1
0
        public void XmlToJsonConverterDoesNotRemovetheRootNodeWhenOmitRootObjectIsSetToTrue()
        {
            //Arrange
            IBaseMessage inputMessage =
                PTL.MessageHelper.CreateFromStream(MessageHelper.LoadMessage("PurchaseOrderWithOutNamespace.xml"));
            var xmlToJsonConverter = new XmlToJsonConverter {
                OmitRootObject = false
            };

            PTL.SendPipelineWrapper testPipelineWrapper = PTL.PipelineFactory.CreateEmptySendPipeline();
            testPipelineWrapper.AddComponent(xmlToJsonConverter, PTL.PipelineStage.Encode);
            //Act
            IBaseMessage outputMessages = testPipelineWrapper.Execute(inputMessage);

            //Assert
            Assert.IsTrue(outputMessages.BodyPart.Data.Position == 0, "The stream position should be zero");
            var     rdr    = new StreamReader(outputMessages.BodyPart.Data);
            string  outMsg = rdr.ReadToEnd();
            JObject json   = JObject.Parse(outMsg);

            Assert.IsNotNull(json);
            JToken po = json.SelectToken("PO");

            Assert.IsTrue(System.String.CompareOrdinal(po.SelectToken("poNum").Value <string>(), "poNum_0") == 0);
        }
示例#2
0
        public static Microsoft.BizTalk.Message.Interop.IBaseMessage Test_FF_Assembler_Pipeline <T1>(Microsoft.BizTalk.Message.Interop.IBaseMessage iBaseMsg)
        {
            Microsoft.BizTalk.Component.Interop.IBaseComponent comp = PTL.Simple.Assembler
                                                                      .FlatFile()
                                                                      .WithDocumentSpec <T1>().End();

            PTL.SendPipelineWrapper pipeline = PTL.Simple.Pipelines.Send()
                                               .WithAssembler(comp)
                                               .WithSpec <T1>();
            // Execute the send pipeline
            Microsoft.BizTalk.Message.Interop.IBaseMessage outputMessage = pipeline.Execute(iBaseMsg);

            return(outputMessage);
        }
示例#3
0
        public void XmlToJsonConverterPcDoesNotRemovesAtTheRateCharactersWhenRemoveAtTheRateCharIsSetToFalse()
        {
            //Arrange
            IBaseMessage inputMessage =
                PTL.MessageHelper.CreateFromStream(MessageHelper.LoadMessage("PurchaseOrder.xml"));
            var xmlToJsonConverter = new XmlToJsonConverter {
                RemoveAtTheRateChar = false
            };

            PTL.SendPipelineWrapper testPipelineWrapper = PTL.PipelineFactory.CreateEmptySendPipeline();
            testPipelineWrapper.AddComponent(xmlToJsonConverter, PTL.PipelineStage.Encode);
            //Act
            IBaseMessage outputMessages = testPipelineWrapper.Execute(inputMessage);

            //Assert
            Assert.IsTrue(outputMessages.BodyPart.Data.Position == 0, "The stream position should be zero");
            var    rdr    = new StreamReader(outputMessages.BodyPart.Data);
            string outMsg = rdr.ReadToEnd();

            Debug.WriteLine("Output Message: " + outMsg);
            Assert.IsTrue(outMsg.IndexOf('@', 0) > 0);
        }
示例#4
0
        public void DotNetTypesToJsonConverter()
        {
            //Arrange
            IBaseMessage inputMessage =
                PTL.MessageHelper.CreateFromStream(MessageHelper.LoadMessage("PurchaseOrder.xml"));
            var dotNetTypesToJsonConverter = new DotNetTypesToJsonConverter {
                TypeName = "PO"
            };

            PTL.SendPipelineWrapper testPipelineWrapper = PTL.PipelineFactory.CreateEmptySendPipeline();
            testPipelineWrapper.AddComponent(dotNetTypesToJsonConverter, PTL.PipelineStage.Encode);

            //Act
            IBaseMessage outputMessages = testPipelineWrapper.Execute(inputMessage);

            //Assert
            Assert.IsTrue(outputMessages.BodyPart.Data.Position == 0, "The stream position should be zero");
            var    rdr    = new StreamReader(outputMessages.BodyPart.Data);
            string outMsg = rdr.ReadToEnd();

            Debug.WriteLine("Output Message: " + outMsg);
            Assert.IsFalse(outMsg.IndexOfAny(new char['@'], 0) == 0);
        }