Esempio n. 1
0
        public void TestHappyPath_TwoWay_HelperClass()
        {
            var testCase = new BizUnit.Core.TestBuilder.TestCase();

            var inMsgStep = new MockSendStep()
            {
                Url         = BizTalkTests.Test.BizTalkTestsMockAddresses.BTS_OneWayReceive2_FILE,
                RequestPath = "StartMessage.xml",
                Encoding    = "UTF-8"
            };

            testCase.ExecutionSteps.Add(inMsgStep);

            var outMsgStep = new MockRequestResponseStep()
            {
                Url          = BizTalkTests.Test.BizTalkTestsMockAddresses.DynamicPortOut2Way,
                Encoding     = "UTF-8",
                ResponsePath = "ResponseMessage.xml",
                Timeout      = 10
            };

            testCase.ExecutionSteps.Add(outMsgStep);

            BizUnit.Core.TestRunner testRunner = new BizUnit.Core.TestRunner(testCase);

            testRunner.Run();
        }
Esempio n. 2
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. 3
0
        public void TestHappyPath_OneWay()
        {
            var testCase = new BizUnit.Core.TestBuilder.TestCase();

            var inMsgStep = new MockSendStep()
            {
                Url         = "mock://localhost/BTS.OneWayReceive_FILE",
                RequestPath = "StartMessage.xml",
                Encoding    = "UTF-8"
            };

            testCase.ExecutionSteps.Add(inMsgStep);

            var outMsgStep = new MockReceiveStep()
            {
                Url      = "mock://localhost/DynamicPortOut",
                Encoding = "UTF-8",
                Timeout  = 10
            };

            testCase.ExecutionSteps.Add(outMsgStep);

            BizUnit.Core.TestRunner testRunner = new BizUnit.Core.TestRunner(testCase);

            testRunner.Run();
        }
Esempio n. 4
0
        public void TestOneWay_HappyPath()
        {
            var testCase = new BizUnit.Core.TestBuilder.TestCase();

            var inMsgStep = new MockSendStep()
            {
                Url         = BizTalkTestsMockAddresses.BTS_OneWayStaticReceive_FILE,
                RequestPath = "StartMessage.xml",
                Encoding    = "UTF-8"
            };

            testCase.ExecutionSteps.Add(inMsgStep);

            var outMsgStep = new MockReceiveStep()
            {
                Url      = BizTalkTestsMockAddresses.BTS_OneWaySendFILE,
                Encoding = "UTF-8",
                Timeout  = 10
            };

            var outMsgValidationStep = new TransMock.Integration.BizUnit.Validation.LambdaValidationStep()
            {
                MessageValidationCallback = (message) => ValidateOutMessage(message)
            };

            outMsgStep.SubSteps.Add(outMsgValidationStep);
            testCase.ExecutionSteps.Add(outMsgStep);

            BizUnit.Core.TestRunner testRunner = new BizUnit.Core.TestRunner(testCase);

            testRunner.Run();
        }
Esempio n. 5
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. 6
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. 7
0
        public void TestOneWay_InboundMessageProperties_HappyPath()
        {
            var testCase = new BizUnit.Core.TestBuilder.TestCase();

            var inMsgStep = new MockSendStep()
            {
                Url         = BizTalkTestsOldMockAddresses.BTS_OneWayReceive2_FILE.ToString(),
                RequestPath = "StartMessage.xml",
                Encoding    = "UTF-8"
            };

            inMsgStep.MessageProperties
            .Add(
                TransMock.Wcf.Adapter.Utils.BizTalkProperties.BTS.Operation,
                "SomeTestOperation");

            testCase.ExecutionSteps.Add(inMsgStep);

            var outMsgStep = new MockReceiveStep()
            {
                Url      = BizTalkTestsOldMockAddresses.BTS_OneWaySendFILE.ToString(),
                Encoding = "UTF-8",
                Timeout  = 10
            };

            var outMsgValidationStep = new TransMock.Integration.BizUnit.Validation.LambdaValidationStep()
            {
                MessageValidationCallback = (message) => ValidateOutMessage(message)
            };

            outMsgStep.SubSteps.Add(outMsgValidationStep);
            testCase.ExecutionSteps.Add(outMsgStep);

            BizUnit.Core.TestRunner testRunner = new BizUnit.Core.TestRunner(testCase);

            testRunner.Run();
        }
Esempio n. 8
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");
        }