Example #1
0
        public void MissingXmlParameter()
        {
            string dir;

            TaskItem[] xmlPaths;
            TaskItem   xslPath;
            TaskItem   xslCompiledPath;

            TaskItem[] outputPaths;
            List <KeyValuePair <XslTransformation.XmlInput.XmlModes, object> >  xmlInputs;
            List <KeyValuePair <XslTransformation.XsltInput.XslModes, object> > xslInputs;
            MockEngine engine;

            Prepare(out dir, out xmlPaths, out xslPath, out xslCompiledPath, out outputPaths, out xmlInputs, out xslInputs, out engine);

            // Test Xml missing.
            for (int xsi = 0; xsi < xslInputs.Count; xsi++)
            {
                XslTransformation t = new XslTransformation();
                t.BuildEngine = engine;
                t.OutputPaths = outputPaths;

                XslTransformation.XsltInput.XslModes xslKey = xslInputs[xsi].Key;
                object xslValue = xslInputs[xsi].Value;
                switch (xslKey)
                {
                case XslTransformation.XsltInput.XslModes.Xslt:
                    t.XslContent = (string)xslValue;
                    break;

                case XslTransformation.XsltInput.XslModes.XsltFile:
                    t.XslInputPath = (TaskItem)xslValue;
                    break;

                case XslTransformation.XsltInput.XslModes.XsltCompiledDll:
                    t.XslCompiledDllPath = (TaskItem)xslValue;
                    break;

                default:
                    Assert.True(false, "Test error");
                    break;
                }

                Assert.False(t.Execute());              // "The test should fail when there is missing Xml params"
                Console.WriteLine(engine.Log);
                Assert.Contains("MSB3701", engine.Log); // "The output should contain MSB3701 error message at missing Xml params test"
                engine.Log = "";
            }

            CleanUp(dir);
        }
Example #2
0
        public void XmlXslParameters()
        {
            string dir;

            TaskItem[] outputPaths;
            List <KeyValuePair <XslTransformation.XmlInput.XmlModes, object> >  xmlInputs;
            List <KeyValuePair <XslTransformation.XsltInput.XslModes, object> > xslInputs;
            MockEngine engine;

            Prepare(out dir, out _, out _, out _, out outputPaths, out xmlInputs, out xslInputs, out engine);

            // Test when Xml and Xsl parameters are correct
            for (int xmi = 0; xmi < xmlInputs.Count; xmi++)
            {
                for (int xsi = 0; xsi < xslInputs.Count; xsi++)
                {
                    XslTransformation t = new XslTransformation();
                    t.BuildEngine = engine;
                    t.OutputPaths = outputPaths;
                    XslTransformation.XmlInput.XmlModes xmlKey = xmlInputs[xmi].Key;
                    object xmlValue = xmlInputs[xmi].Value;
                    XslTransformation.XsltInput.XslModes xslKey = xslInputs[xsi].Key;
                    object xslValue = xslInputs[xsi].Value;

                    switch (xmlKey)
                    {
                    case XslTransformation.XmlInput.XmlModes.Xml:
                        t.XmlContent = (string)xmlValue;
                        break;

                    case XslTransformation.XmlInput.XmlModes.XmlFile:
                        t.XmlInputPaths = (TaskItem[])xmlValue;
                        break;

                    default:
                        Assert.True(false, "Test error");
                        break;
                    }

                    switch (xslKey)
                    {
                    case XslTransformation.XsltInput.XslModes.Xslt:
                        t.XslContent = (string)xslValue;
                        break;

                    case XslTransformation.XsltInput.XslModes.XsltFile:
                        t.XslInputPath = (TaskItem)xslValue;
                        break;

                    case XslTransformation.XsltInput.XslModes.XsltCompiledDll:
                        t.XslCompiledDllPath = (TaskItem)xslValue;
                        break;

                    default:
                        Assert.True(false, "Test error");
                        break;
                    }

                    Assert.True(t.Execute()); // "The test should have passed at the both params correct test"
                }
            }

            CleanUp(dir);
        }