Пример #1
0
            public void Should_Throw_If_Xsl_Was_Null()
            {
                // Given
                var xml = Resources.XmlTransformation_Xml;

                // When
                var result = Record.Exception(() => XmlTransformation.Transform(null, xml));

                // Then
                AssertEx.IsArgumentNullException(result, "xsl");
            }
Пример #2
0
            public void Should_Throw_If_String_Settings_Was_Null()
            {
                // Given
                var xml = Resources.XmlTransformation_Xml;
                var xsl = Resources.XmlTransformation_Xsl;

                // When
                var result = Record.Exception(() => XmlTransformation.Transform(xsl, xml, null));

                // Then
                AssertEx.IsArgumentNullException(result, "settings");
            }
Пример #3
0
            public void Should_Transform_Xml_String_And_Xsl_String_To_Result_String()
            {
                // Given
                var xml = Resources.XmlTransformation_Xml;
                var xsl = Resources.XmlTransformation_Xsl;
                var htm = Resources.XmlTransformation_Htm_NoXmlDeclaration;

                // When
                var result = XmlTransformation.Transform(xsl, xml);

                // Then
                Assert.Equal(htm, result, ignoreLineEndingDifferences: true);
            }
Пример #4
0
            public void Should_Transform_Xml_String_And_Xsl_String_To_Result_String_With_Utf32Xml_Declaration()
            {
                // Given
                var xml      = Resources.XmlTransformation_Xml;
                var xsl      = Resources.XmlTransformation_Xsl;
                var settings = new XmlTransformationSettings
                {
                    Encoding = new UTF32Encoding(false, false, true)
                };

                // When
                var result = string.Concat(XmlTransformation.Transform(xsl, xml, settings).Take(39));

                // Then
                Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-32\"?>", result);
            }
Пример #5
0
            public void Should_Not_Throw_If_Xsl_Argument_List_Was_Null()
            {
                // Given
                var xml = Resources.XmlTransformation_Xml;
                var xsl = Resources.XmlTransformation_Xsl;
                XmlTransformationSettings xmlTransformationSettings = new XmlTransformationSettings
                {
                    XsltArgumentList = null
                };

                // When
                var result = Record.Exception(() => XmlTransformation.Transform(xsl, xml, xmlTransformationSettings));

                // Then
                Assert.Null(result);
            }
Пример #6
0
            public void Should_Transform_Xml_String_And_Xsl_String_To_Result_String_With_Xml_Declaration()
            {
                // Given
                var xml      = Resources.XmlTransformation_Xml;
                var xsl      = Resources.XmlTransformation_Xsl;
                var htm      = Resources.XmlTransformation_Htm;
                var settings = new XmlTransformationSettings
                {
                    Encoding = new UTF8Encoding(false)
                };

                // When
                var result = XmlTransformation.Transform(xsl, xml, settings);

                // Then
                Assert.Equal(htm, result, ignoreLineEndingDifferences: true);
            }
Пример #7
0
            public void Should_Transform_Xml_String_And_Xsl_String_WithArgumentsAndNamespace_To_Result_String()
            {
                // Given
                var xml = Resources.XmlTransformation_Xml;
                var xsl = Resources.XmlTransformationWithArgumentsAndNamespace_Xsl;
                var htm = Resources.XmlTransformation_Htm_NoXmlDeclaration;
                XmlTransformationSettings xmlTransformationSettings = new XmlTransformationSettings
                {
                    OmitXmlDeclaration = true,
                    Encoding           = new UTF8Encoding(false),
                    XsltArgumentList   = new XsltArgumentList()
                };

                xmlTransformationSettings.XsltArgumentList.AddParam("BackgroundColor", "http://example.com", "teal");
                xmlTransformationSettings.XsltArgumentList.AddParam("Color", "http://example.com", "white");

                // When
                var result = XmlTransformation.Transform(xsl, xml, xmlTransformationSettings);

                // Then
                Assert.Equal(htm, result, ignoreLineEndingDifferences: true);
            }
Пример #8
0
 public void Transform()
 {
     XmlTransformation.Transform(FileSystem, XslPath, XmlPath, ResultPath, Settings);
 }