Esempio n. 1
0
        public void TestSendSmallMessage_FlatFile()
        {
            //Setting up the ILogger moq
            var loggerMock = CreateLoggerMock();

            Context context = new Context(loggerMock.Object);

            MockSendStep step = new MockSendStep();

            step.Url         = connectionUri.Uri.OriginalString;
            step.RequestPath = "TestRequest.txt";
            step.Encoding    = "UTF-8";
            step.Timeout     = 30;
            //Validated the step
            step.Validate(context);
            //Executing the step
            step.Execute(context);

            //Now we read the message in the inbound handler
            Message       msg = null;
            IInboundReply reply;

            inboundHandler.TryReceive(TimeSpan.FromSeconds(10), out msg, out reply);

            Assert.IsNotNull(msg, "Message instance was not returned");
            Assert.AreEqual(ReadRequestFileContent(step.RequestPath),
                            GeneralTestHelper.GetBodyAsString(msg, Encoding.UTF8), "Message contents of received message is different");

            loggerMock.Verify(l => l.LogData(
                                  It.Is <string>(s => !string.IsNullOrEmpty(s)),
                                  It.Is <string>(s => !string.IsNullOrEmpty(s))), Times.AtLeastOnce(), "The LogData message was not called");
        }
Esempio n. 2
0
        public void TestValidateMethod_ValidStep()
        {
            var loggerMock = CreateLoggerMock();

            Context      context = new Context(loggerMock.Object);
            MockSendStep step    = new MockSendStep();

            step.Url         = connectionUri.Uri.OriginalString;
            step.RequestPath = "TestRequest.xml";
            step.Encoding    = "UTF-8";
            //Colling Validate in order to start the
            step.Validate(context);
            step = null;
        }
Esempio n. 3
0
        public void TestOneWay_XML()
        {
            //Setting up the ILogger moq
            var loggerMock = CreateLoggerMock();

            Context context = new Context(loggerMock.Object);

            MockSendStep sendDtep = new MockSendStep()
            {
                Url         = "mock://localhost/OneWayReceive",
                RequestPath = "TestRequest.xml",
                Encoding    = "UTF-8",
                Timeout     = 30
            };

            //Validated the step
            sendDtep.Validate(context);
            //Executing the step
            sendDtep.Execute(context);

            loggerMock.Verify(l => l.LogData(
                                  It.Is <string>(s => !string.IsNullOrEmpty(s) &&
                                                 s == "Reading request content from path TestRequest.xml"),
                                  It.Is <string>(s => !string.IsNullOrEmpty(s) &&
                                                 s == File.ReadAllText("TestRequest.xml"))),
                              Times.AtLeastOnce(),
                              "The LogData message was not called");

            //Now we receive the message
            MockReceiveStep receiveStep = new MockReceiveStep()
            {
                Url      = "mock://localhost/OneWaySend",
                Encoding = "UTF-8"
            };

            // Calling Validate to start the receive server
            receiveStep.Validate(context);

            // Executing the step
            receiveStep.Execute(context);

            loggerMock.Verify(l => l.LogData(
                                  It.Is <string>(s => !string.IsNullOrEmpty(s) &&
                                                 s == "MockReceiveStep received a message with content"),
                                  It.Is <string>(s => !string.IsNullOrEmpty(s) &&
                                                 s == File.ReadAllText("TestRequest.xml"))),
                              Times.AtLeastOnce(),
                              "The LogData message was not called");
        }
Esempio n. 4
0
        public void TestSendSmallMessage_XML_MessageProperties()
        {
            //Setting up the ILogger moq
            var loggerMock = CreateLoggerMock();

            Context context = new Context(loggerMock.Object);

            MockSendStep step = new MockSendStep();

            step.Url         = connectionUri.Uri.OriginalString;
            step.RequestPath = "TestRequest.xml";
            step.Encoding    = "UTF-8";
            step.Timeout     = 30;

            step.MessageProperties.Add(
                Utils.BizTalkProperties.BTS.Operation,
                "SomeTestOperation.com");

            step.MessageProperties.Add(
                Utils.BizTalkProperties.FILE.ReceivedFileName,
                @"\blabla\bla\TestFile.xml");
            //Validating the test step
            step.Validate(context);
            //Executing the step
            step.Execute(context);

            //Now we read the message in the inbound handler
            Message       msg = null;
            IInboundReply reply;

            inboundHandler.TryReceive(TimeSpan.FromSeconds(10), out msg, out reply);

            Assert.IsNotNull(msg, "Message instance was not returned");
            Assert.AreEqual(ReadRequestFileContent(step.RequestPath),
                            GeneralTestHelper.GetBodyAsString(msg, Encoding.UTF8), "Message contents of received message is different");

            loggerMock.Verify(l => l.LogData(
                                  It.Is <string>(s => !string.IsNullOrEmpty(s)),
                                  It.Is <string>(s => !string.IsNullOrEmpty(s))), Times.AtLeastOnce(), "The LogData message was not called");

            //Verify the promoted properties
            var promotedProperties = msg.Properties
                                     .Where(p => p.Key == "http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties/Promote")
                                     .SingleOrDefault();

            Assert.IsNotNull(promotedProperties, "The promoted properties list is not present");

            var propertiesList = promotedProperties.Value as List <KeyValuePair <XmlQualifiedName, object> >;

            Assert.AreEqual(2, propertiesList.Count, "The element count in the promoted properties list differ");

            MessagePropertyValidator
            .ValidatePromotedProperty(propertiesList[0],
                                      "http://schemas.microsoft.com/BizTalk/2003/system-properties",
                                      "Operation",
                                      @"SomeTestOperation.com");

            MessagePropertyValidator
            .ValidatePromotedProperty(propertiesList[1],
                                      "http://schemas.microsoft.com/BizTalk/2003/file-properties",
                                      "ReceivedFileName",
                                      @"\blabla\bla\TestFile.xml");
        }