Exemplo n.º 1
0
		public void Migrate_TestData_TransformsOk()
		{
			string xsl = @"<?xml version=""1.0"" encoding=""UTF-8"" ?>
<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
  <!-- don't do anything to other versions -->
  <xsl:template match=""configuration[@version='1']"">
	<configuration version=""2"">
	  <xsl:apply-templates mode =""identity""/>
	</configuration>
  </xsl:template>

  <xsl:template match=""@*|node()"" mode=""identity"">
	<xsl:copy>
	  <xsl:apply-templates select=""@*|node()""  mode=""identity""/>
	</xsl:copy>
  </xsl:template>
</xsl:stylesheet>
";

			string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<configuration version='1'>
  <blah />
</configuration>
".Replace("'", "\"");

			using (var sourceFile = new TempFile(xml))
			{
				using (var destinationFile = new TempFile())
				{
					var migrator = new XslStringMigrator(1, 2, xsl);
					migrator.Migrate(sourceFile.Path, destinationFile.Path);
					AssertThatXmlIn.File(destinationFile.Path).HasAtLeastOneMatchForXpath("configuration[@version='2']");
					AssertThatXmlIn.File(destinationFile.Path).HasAtLeastOneMatchForXpath("/configuration/blah");
				}
			}
		}
Exemplo n.º 2
0
        public void Migrate_TestData_TransformsOk()
        {
            string xsl = @"<?xml version=""1.0"" encoding=""UTF-8"" ?>
<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
  <!-- don't do anything to other versions -->
  <xsl:template match=""configuration[@version='1']"">
	<configuration version=""2"">
	  <xsl:apply-templates mode =""identity""/>
	</configuration>
  </xsl:template>

  <xsl:template match=""@*|node()"" mode=""identity"">
	<xsl:copy>
	  <xsl:apply-templates select=""@*|node()""  mode=""identity""/>
	</xsl:copy>
  </xsl:template>
</xsl:stylesheet>
";

            string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<configuration version='1'>
  <blah />
</configuration>
".Replace("'", "\"");

            using (var sourceFile = new TempFile(xml))
            {
                using (var destinationFile = new TempFile())
                {
                    var migrator = new XslStringMigrator(1, 2, xsl);
                    migrator.Migrate(sourceFile.Path, destinationFile.Path);
                    AssertThatXmlIn.File(destinationFile.Path).HasAtLeastOneMatchForXpath("configuration[@version='2']");
                    AssertThatXmlIn.File(destinationFile.Path).HasAtLeastOneMatchForXpath("/configuration/blah");
                }
            }
        }
Exemplo n.º 3
0
		public void Constructor_FromLessThanTo_Throws()
		{
			Assert.Throws<ArgumentException>(
				() => { var migrator = new XslStringMigrator(5, 4, null); }
			);
		}
Exemplo n.º 4
0
 public void Constructor_FromLessThanTo_Throws()
 {
     Assert.Throws <ArgumentException>(
         () => { var migrator = new XslStringMigrator(5, 4, null); }
         );
 }