我正在使用伟大的Winterdom BizTalk测试库来测试将平面文件转换为15个记录。
部署到BizTalk时,接收管道工作正常。
这是我的单元测试:
[DeploymentItem(@"TestData\Maps\FromCarrier\UPSSampleUpdate.csv")]
[TestMethod]
public void UPSTrackTrace_DebatchAndConvertUPSUpdateFFToXml()
{
FFDisassembler ff = Disassembler.FlatFile().WithHeaderSpec<Vasanta.Int.Carrier.Schemas.Carriers.UPS.TrackAndTrace.TandTHeader>();
ff.WithDocumentSpec<Vasanta.Int.Carrier.Schemas.Carriers.UPS.TrackAndTrace.TandTBody>();
ReceivePipelineWrapper pipeline = Pipelines.Receive().WithDisassembler(ff);
// Create the input message to pass through the pipeline
MemoryStream stream = new MemoryStream();
using (FileStream file = new FileStream("UPSSampleUpdate.csv", FileMode.Open, FileAccess.Read))
{
byte[] bytes = new byte[file.Length];
file.Read(bytes, 0, (int)file.Length);
stream.Write(bytes, 0, (int)file.Length);
}
IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);
MessageCollection output = pipeline.Execute(inputMessage);
Assert.AreEqual(15, output.Count);
}
运行测试会引发以下错误: 测试方法
Vasanta.Int.Carrier.UnitTests.Pipelines.FromCarrier.UPSUpdateFFDisassemble.UPSTrackTrace_DebatchAndConvertUPSUpdateFFToXml threw exception:
System.Xml.XmlException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
And this stack trace:
Microsoft.BizTalk.ParsingEngine.UngetBuffer.Push(String str, Int32 index, Int32 howMany)
Microsoft.BizTalk.ParsingEngine.DataReader.Unget(String str, Int32 index, Int32 count)
Microsoft.BizTalk.ParsingEngine.FFScanner.MatchDelimited()
Microsoft.BizTalk.ParsingEngine.FFScanner.Match()
Microsoft.BizTalk.ParsingEngine.FFScanner.InternalRead()
Microsoft.BizTalk.ParsingEngine.BufferedTokenReader.Read()
Microsoft.BizTalk.ParsingEngine.FFScanner.Read()
Microsoft.BizTalk.ParsingEngine.Parser.Scan()
Microsoft.BizTalk.ParsingEngine.Parser.Resume()
Microsoft.BizTalk.ParsingEngine.Parser.Parse()
Microsoft.BizTalk.ParsingEngine.FFReader.State.InitialState.Read(FFReader reader)
Microsoft.BizTalk.ParsingEngine.FFReader.State.InitialState.Read(FFReader reader)
Microsoft.BizTalk.ParsingEngine.FFReader.Read()
Microsoft.BizTalk.Streaming.XmlTranslatorStream.ProcessXmlNodes(Int32 count)
Microsoft.BizTalk.Streaming.XmlBufferedReaderStream.ReadInternal(Byte[] buffer, Int32 offset, Int32 count)
Microsoft.BizTalk.Streaming.EventingReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
Microsoft.BizTalk.Streaming.MarkableForwardOnlyEventingReadStream.ReadInternal(Byte[] buffer, Int32 offset, Int32 count)
Microsoft.BizTalk.Streaming.EventingReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
System.IO.StreamReader.ReadBuffer(Char[] userBuffer, Int32 userOffset, Int32 desiredChars, Boolean& readToUserBuffer)
System.IO.StreamReader.Read(Char[] buffer, Int32 index, Int32 count)
System.Xml.XmlTextReaderImpl.ReadData()
System.Xml.XmlTextReaderImpl.InitTextReaderInput(String baseUriStr, Uri baseUri, TextReader input)
System.Xml.XmlTextReaderImpl..ctor(String url, TextReader input, XmlNameTable nt)
System.Xml.XmlTextReader..ctor(TextReader input)
Microsoft.BizTalk.Component.XmlDasmReader.GetReader(Boolean bValidate, Stream data, Encoding encoding, SchemaList envelopeSpecNames, SchemaList documentSpecNames)
Microsoft.BizTalk.Component.XmlDasmReader..ctor(IPipelineContext pipelineContext, IBaseMessageContext msgctx, Stream data, Encoding encoding, Boolean saveEnvelopes, XPathAnnotationCollection xac, NodeProcessor defaultProcessor, Boolean allowUnrecognizedMessage, Boolean validateDocument, SchemaList envelopeSpecNames, SchemaList documentSpecNames, MsgTypeSchema schemaList, Boolean promoteProperties, Boolean bamTracking, SuspendCurrentMessageFunction documentScanner)
Microsoft.BizTalk.Component.XmlDasmReader.CreateReader(IPipelineContext pipelineContext, IBaseMessageContext messageContext, MarkableForwardOnlyEventingReadStream data, Encoding encoding, Boolean saveEnvelopes, Boolean allowUnrecognizedMessage, Boolean validateDocument, SchemaList envelopeSpecNames, SchemaList documentSpecNames, IFFDocumentSpec docSpecType, SuspendCurrentMessageFunction documentScanner)
Microsoft.BizTalk.Component.FFDasmComp.Disassemble2(IPipelineContext pc, IBaseMessage inMsg)
Microsoft.BizTalk.Component.FFDasmComp.Disassemble(IPipelineContext pc, IBaseMessage inMsg)
Microsoft.Test.BizTalk.PipelineObjects.Stage.Execute(IPipelineContext pipelineContext, IBaseMessage inputMessage)
Microsoft.Test.BizTalk.PipelineObjects.GenericPipeline.ExecuteSubPipeline(IPipelineContext pipelineContext, IBaseMessage inputMessage, Int32 startStageIndex, Int32 endStageIndex)
Microsoft.Test.BizTalk.PipelineObjects.ReceivePipeline.Execute(IPipelineContext pipelineContext)
Winterdom.BizTalk.PipelineTesting.ReceivePipelineWrapper.Execute(IBaseMessage inputMessage)
x.Int.Carrier.UnitTests.Pipelines.FromCarrier.UPSUpdateFFDisassemble.UPSTrackTrace_DebatchAndConvertUPSUpdateFFToXml() in C:\Development\x.Int.Carrier\Dev\V1.0\Src\Solutions\Carrier\x.Int.Carrier.UnitTests\Pipelines\FromCarrier\UPSUpdateFFDisassemble.cs: line 59
谁能看到我哪里出错?
答案 0 :(得分:0)
可能不是你。 BizTalk运行时中存在许多“事物”,这些“事物”不会被任何管道测试工具重新创建。
您最好的选择是下载源代码并在Visual Studio中运行它以查看它的中断位置。
旁注:我在BizTalk中运行所有测试。