Advertisement
Guest User

Untitled

a guest
May 27th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using BizTalkComponents.Utils;
  4. using Microsoft.VisualStudio.TestTools.UnitTesting;
  5. using Winterdom.BizTalk.PipelineTesting;
  6.  
  7. namespace BizTalkComponents.PipelineComponents.PromoteDateTimeFileName.Tests.UnitTests
  8. {
  9. [TestClass]
  10. public class PromoteDateTimeFileNameTests
  11. {
  12. [TestMethod]
  13. [ExpectedException(typeof(ArgumentException))]
  14. public void TestNullFormat()
  15. {
  16. var pipeline = PipelineFactory.CreateEmptySendPipeline();
  17.  
  18. var component = new PromoteDateTimeFileName();
  19.  
  20. pipeline.AddComponent(component, PipelineStage.PreAssemble);
  21. var message = MessageHelper.Create("<test></test>");
  22.  
  23. var outout = pipeline.Execute(message);
  24. }
  25.  
  26. [TestMethod]
  27. public void TestPromoteDate()
  28. {
  29. var pipeline = PipelineFactory.CreateEmptySendPipeline();
  30. var dateFormat = "yyyy-MM-dd";
  31. var component = new PromoteDateTimeFileName
  32. {
  33. DateFormat = dateFormat
  34. };
  35.  
  36. pipeline.AddComponent(component, PipelineStage.PreAssemble);
  37. var message = MessageHelper.Create("<test></test>");
  38.  
  39. var output = pipeline.Execute(message);
  40. var fileName = message.Context.Read(new ContextProperty(FileProperties.ReceivedFileName)) as string;
  41.  
  42. Assert.IsFalse(string.IsNullOrEmpty(fileName));
  43. DateTime dateTime;
  44. Assert.IsTrue(DateTime.TryParseExact(fileName,dateFormat,null, DateTimeStyles.None, out dateTime));
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement