public void SetFileName_ShouldIncludeSourceFilename() { var component = new SetFileName() { IncludeOriginalFilename = true }; pipeline.AddComponent(component, PipelineStage.Encode); var result = pipeline.Execute(msg); string newFileName = result.Context.Read(receivedFileName.PropertyName, receivedFileName.PropertyNamespace).ToString(); Assert.AreEqual(originalFileName, newFileName); }
public void SetFileName_ShouldChangeExtension() { var component = new SetFileName() { IncludeOriginalFilename = true, Extension = ".txt" }; pipeline.AddComponent(component, PipelineStage.Encode); var result = pipeline.Execute(msg); string newFileName = result.Context.Read(receivedFileName.PropertyName, receivedFileName.PropertyNamespace).ToString(); Assert.AreEqual(Path.GetFileNameWithoutExtension(originalFileName) + ".txt", newFileName); }
public void SetFileName_ShouldIncludeDateInCorrectFormat() { var component = new SetFileName() { IncludeDate = true, DateFormat = "yyyy-MM" }; pipeline.AddComponent(component, PipelineStage.Encode); var result = pipeline.Execute(msg); string newFileName = result.Context.Read(receivedFileName.PropertyName, receivedFileName.PropertyNamespace).ToString(); Assert.AreEqual(DateTime.Now.ToString(component.DateFormat) + ".xml", newFileName); }
public void SetFileName_ShouldIncludeValuesFromXPaths() { var component = new SetFileName() { XPath1 = "/root/element1[1]", XPath2 = "/root/element2[1]", XPath3 = "/root/element3[1]" }; pipeline.AddComponent(component, PipelineStage.Encode); var result = pipeline.Execute(msg); string newFileName = result.Context.Read(receivedFileName.PropertyName, receivedFileName.PropertyNamespace).ToString(); Assert.AreEqual("value1_value2_value3.xml", newFileName); }
public void SetFileName_ShouldNotThrow_WhenXPathDoesNotFindValue() { var component = new SetFileName() { IncludeOriginalFilename = true, XPath1 = "/notfound/element1[1]", XPath2 = "/root/notfound[1]", }; pipeline.AddComponent(component, PipelineStage.Encode); var result = pipeline.Execute(msg); string newFileName = result.Context.Read(receivedFileName.PropertyName, receivedFileName.PropertyNamespace).ToString(); Assert.AreEqual(originalFileName, newFileName); }
public void SetFileName_ShouldThrow_WhenFileNameContainsIllegalCharacters() { var component = new SetFileName() { XPath1 = "/root/element[1]" }; pipeline.AddComponent(component, PipelineStage.Encode); string inputXml = @"<root> <element>:</element> </root>"; string expectedXml = inputXml; var msg = MessageHelper.Create(inputXml); msg.Context.Write(receivedFileName.PropertyName, receivedFileName.PropertyNamespace, originalFileName); var result = pipeline.Execute(msg); }