From aa5a5e492f9a7060720056c27963cf1d06b4737f Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 15 Oct 2019 11:12:57 +1000 Subject: Add failing test for AsString on a number field with 0. --- .../MsiQueryFixture.cs | 32 +++++++++++++++++ .../TestData/TypeLib/Language0.wxs | 11 ++++++ .../WixToolsetTest.CoreIntegration.csproj | 1 + .../WixlibQueryFixture.cs | 40 ++++++++++++++++++++-- 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/TypeLib/Language0.wxs (limited to 'src') diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs index 6fea6e36..e2a672b7 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs @@ -680,6 +680,38 @@ namespace WixToolsetTest.CoreIntegration } } + [Fact] + public void PopulatesTypeLibTableWhenLanguageIsZero() + { + var folder = TestData.Get(@"TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "TypeLib", "Language0.wxs"), + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), + "-bindpath", Path.Combine(folder, "SingleFile", "data"), + "-intermediateFolder", intermediateFolder, + "-o", msiPath + }); + + result.AssertSuccess(); + + Assert.True(File.Exists(msiPath)); + var results = Query.QueryDatabase(msiPath, new[] { "TypeLib" }); + Assert.Equal(new[] + { + "TypeLib:{765BE8EE-BD7F-491E-90D2-C5A972462B50}\t0\tTypeLibComp\t\t\t\tProductFeature\t", + }, results); + } + } + [Fact] public void PopulatesUpgradeTableFromManualUpgrade() { diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/TypeLib/Language0.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/TypeLib/Language0.wxs new file mode 100644 index 00000000..fa64f98f --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/TypeLib/Language0.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj index 0624f6ae..770f528a 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj @@ -114,6 +114,7 @@ + diff --git a/src/test/WixToolsetTest.CoreIntegration/WixlibQueryFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WixlibQueryFixture.cs index 88491eac..061eae07 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixlibQueryFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/WixlibQueryFixture.cs @@ -21,18 +21,19 @@ namespace WixToolsetTest.CoreIntegration { var baseFolder = fs.GetFolder(); var intermediateFolder = Path.Combine(baseFolder, "obj"); + var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); var result = WixRunner.Execute(new[] { "build", Path.Combine(folder, "DetectOnly.wxs"), "-intermediateFolder", intermediateFolder, - "-o", Path.Combine(intermediateFolder, @"test.wixlib"), + "-o", wixlibPath, }); result.AssertSuccess(); - var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wixlib")); + var intermediate = Intermediate.Load(wixlibPath); var allTuples = intermediate.Sections.SelectMany(s => s.Tuples); var wixSimpleRefTuples = allTuples.OfType(); var repRef = wixSimpleRefTuples.Where(t => t.Table == "WixAction" && @@ -41,5 +42,40 @@ namespace WixToolsetTest.CoreIntegration Assert.NotNull(repRef); } } + + [Fact(Skip = "Test demonstrates failure")] + public void TypeLibLanguageAsStringReturnsZero() + { + var folder = TestData.Get(@"TestData\TypeLib"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "Language0.wxs"), + "-intermediateFolder", intermediateFolder, + "-o", wixlibPath + }); + + result.AssertSuccess(); + + var intermediate = Intermediate.Load(wixlibPath); + var allTuples = intermediate.Sections.SelectMany(s => s.Tuples); + var typeLibTuple = allTuples.OfType() + .SingleOrDefault(); + Assert.NotNull(typeLibTuple); + + var fields = typeLibTuple.Fields.Select(field => field?.Type == IntermediateFieldType.Bool + ? field.AsNullableNumber()?.ToString() + : field?.AsString()) + .ToList(); + Assert.Equal("0", fields[1]); + } + } } } -- cgit v1.2.3-55-g6feb