Inheritance: WebServiceContainerMock
Ejemplo n.º 1
0
        //[TestMethod]
        //public void WebServiceContainerExecuteWithValidServiceHavingInputsExpectedExecutesService()
        //{
        //    var container = CreateWebServiceContainer(WebServiceWithInputsXml, WebSourceWithInputsXml, WebServiceWithInputsResponseXml.ToString());

        //    ErrorResultTO errors;
        //    var dataListID = container.Execute(out errors, 0);
        //    var compiler = DataListFactory.CreateDataListCompiler();

        //    var result = compiler.ConvertFrom(dataListID, DataListFormat.CreateFormat(GlobalConstants._XML), enTranslationDepth.Data, out errors);

        //    Assert.IsNotNull(result);

        //    var resultXml = XElement.Parse(result.ToString());

        //    var expectedRoot = (XElement)WebServiceWithInputsResponseXml.FirstNode;
        //    foreach(var actualNode in resultXml.Elements())
        //    {
        //        var actualName = actualNode.Name.LocalName;
        //        if(!actualName.StartsWith("Dev2System"))
        //        {
        //            var expectedNode = expectedRoot.Element(actualName);
        //            if(expectedNode != null)
        //            {
        //                Assert.AreEqual(expectedNode.Value, actualNode.Value);
        //            }
        //        }
        //    }
        //}

        //[TestMethod]
        //public void WebServiceContainerExecuteWithValidServiceHavingNoInputsExpectedExecutesService()
        //{
        //    var container = CreateWebServiceContainer(WebServiceWithoutInputsXml, WebSourceWithoutInputsXml, WebServiceWithoutInputsResponse);

        //    ErrorResultTO errors;
        //    var dataListId = container.Execute(out errors, 0);
        //    var compiler = DataListFactory.CreateDataListCompiler();

        //    var result = compiler.ConvertFrom(dataListId, DataListFormat.CreateFormat(GlobalConstants._XML), enTranslationDepth.Data, out errors);

        //    Assert.IsNotNull(result);

        //    var resultXml = XElement.Parse(result.ToString());

        //    var expectedRoot = WebServiceWithoutInputsResponseXml;
        //    foreach(var actualNode in resultXml.Elements())
        //    {
        //        var actualName = actualNode.Name.LocalName;
        //        if(!actualName.StartsWith("Dev2System"))
        //        {
        //            var expectedNode = expectedRoot.Element(actualName);
        //            if(expectedNode != null)
        //            {
        //                Assert.AreEqual(expectedNode.Value, actualNode.Value);
        //            }
        //        }
        //    }
        //}

        #endregion

        #region CreateWebServiceContainer

        static WebServiceContainer CreateWebServiceContainer(XElement serviceXml, XElement sourceXml, string response, bool isFaulty = false)
        {
            var dataObj = new Mock <IDSFDataObject>();

            dataObj.Setup(d => d.DataListID).Returns(new Guid());

            var workspace  = new Mock <IWorkspace>();
            var esbChannel = new Mock <IEsbChannel>();

            var sa = CreateServiceAction(serviceXml, sourceXml);
            WebServiceContainer container;

            if (!isFaulty)
            {
                container = new WebServiceContainerMock(sa, dataObj.Object, workspace.Object, esbChannel.Object)
                {
                    WebRequestRespsonse = response
                };
            }
            else
            {
                container = new FaultyWebServiceContainerMock(sa, dataObj.Object, workspace.Object, esbChannel.Object)
                {
                    WebRequestRespsonse = string.Empty
                };
            }

            return(container);
        }
Ejemplo n.º 2
0
        static WebServiceContainer CreateWebServiceContainer(XElement serviceXml, XElement sourceXml, string response, bool isFaulty = false)
        {
            ErrorResultTO errors;
            var           compiler   = DataListFactory.CreateDataListCompiler();
            var           dataListId = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), "".ToStringBuilder(), "<DataList></DataList>".ToStringBuilder(), out errors);

            var dataObj = new Mock <IDSFDataObject>();

            dataObj.Setup(d => d.DataListID).Returns(dataListId);

            var workspace  = new Mock <IWorkspace>();
            var esbChannel = new Mock <IEsbChannel>();

            var sa = CreateServiceAction(serviceXml, sourceXml);
            WebServiceContainer container;

            if (!isFaulty)
            {
                container = new WebServiceContainerMock(sa, dataObj.Object, workspace.Object, esbChannel.Object)
                {
                    WebRequestRespsonse = response
                };
            }
            else
            {
                container = new FaultyWebServiceContainerMock(sa, dataObj.Object, workspace.Object, esbChannel.Object)
                {
                    WebRequestRespsonse = string.Empty
                };
            }

            return(container);
        }
        //[TestMethod]
        //public void WebServiceContainerExecuteWithValidServiceHavingInputsExpectedExecutesService()
        //{
        //    var container = CreateWebServiceContainer(WebServiceWithInputsXml, WebSourceWithInputsXml, WebServiceWithInputsResponseXml.ToString());

        //    ErrorResultTO errors;
        //    var dataListID = container.Execute(out errors, 0);
        //    var compiler = DataListFactory.CreateDataListCompiler();

        //    var result = compiler.ConvertFrom(dataListID, DataListFormat.CreateFormat(GlobalConstants._XML), enTranslationDepth.Data, out errors);

        //    Assert.IsNotNull(result);

        //    var resultXml = XElement.Parse(result.ToString());

        //    var expectedRoot = (XElement)WebServiceWithInputsResponseXml.FirstNode;
        //    foreach(var actualNode in resultXml.Elements())
        //    {
        //        var actualName = actualNode.Name.LocalName;
        //        if(!actualName.StartsWith("Dev2System"))
        //        {
        //            var expectedNode = expectedRoot.Element(actualName);
        //            if(expectedNode != null)
        //            {
        //                Assert.AreEqual(expectedNode.Value, actualNode.Value);
        //            }
        //        }
        //    }
        //}

        //[TestMethod]
        //public void WebServiceContainerExecuteWithValidServiceHavingNoInputsExpectedExecutesService()
        //{
        //    var container = CreateWebServiceContainer(WebServiceWithoutInputsXml, WebSourceWithoutInputsXml, WebServiceWithoutInputsResponse);

        //    ErrorResultTO errors;
        //    var dataListId = container.Execute(out errors, 0);
        //    var compiler = DataListFactory.CreateDataListCompiler();

        //    var result = compiler.ConvertFrom(dataListId, DataListFormat.CreateFormat(GlobalConstants._XML), enTranslationDepth.Data, out errors);

        //    Assert.IsNotNull(result);

        //    var resultXml = XElement.Parse(result.ToString());

        //    var expectedRoot = WebServiceWithoutInputsResponseXml;
        //    foreach(var actualNode in resultXml.Elements())
        //    {
        //        var actualName = actualNode.Name.LocalName;
        //        if(!actualName.StartsWith("Dev2System"))
        //        {
        //            var expectedNode = expectedRoot.Element(actualName);
        //            if(expectedNode != null)
        //            {
        //                Assert.AreEqual(expectedNode.Value, actualNode.Value);
        //            }
        //        }
        //    }
        //}

        #endregion

        #region CreateWebServiceContainer

        static WebServiceContainer CreateWebServiceContainer(XElement serviceXml, XElement sourceXml, string response, bool isFaulty = false)
        {

            var dataObj = new Mock<IDSFDataObject>();
            dataObj.Setup(d => d.DataListID).Returns(new Guid());

            var workspace = new Mock<IWorkspace>();
            var esbChannel = new Mock<IEsbChannel>();

            var sa = CreateServiceAction(serviceXml, sourceXml);
            WebServiceContainer container;

            if(!isFaulty)
            {

                container = new WebServiceContainerMock(sa, dataObj.Object, workspace.Object, esbChannel.Object)
                {
                    WebRequestRespsonse = response
                };
            }
            else
            {
                container = new FaultyWebServiceContainerMock(sa, dataObj.Object, workspace.Object, esbChannel.Object)
                {
                    WebRequestRespsonse = string.Empty
                };
            }

            return container;
        }
        static WebServiceContainer CreateWebServiceContainer(XElement serviceXml, XElement sourceXml, string response, bool isFaulty = false)
        {
            ErrorResultTO errors;
            var compiler = DataListFactory.CreateDataListCompiler();
            var dataListId = compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), "".ToStringBuilder(), "<DataList></DataList>".ToStringBuilder(), out errors);

            var dataObj = new Mock<IDSFDataObject>();
            dataObj.Setup(d => d.DataListID).Returns(dataListId);

            var workspace = new Mock<IWorkspace>();
            var esbChannel = new Mock<IEsbChannel>();

            var sa = CreateServiceAction(serviceXml, sourceXml);
            WebServiceContainer container;

            if(!isFaulty)
            {

                container = new WebServiceContainerMock(sa, dataObj.Object, workspace.Object, esbChannel.Object)
                {
                    WebRequestRespsonse = response
                };
            }
            else
            {
                container = new FaultyWebServiceContainerMock(sa, dataObj.Object, workspace.Object, esbChannel.Object)
                {
                    WebRequestRespsonse = string.Empty
                };
            }

            return container;
        }