| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolsetTest.CoreIntegration |
| 4 | { |
| 5 | using System.IO; |
| 6 | using System.Linq; |
| 7 | using WixInternal.Core.TestPackage; |
| 8 | using WixInternal.TestSupport; |
| 9 | using Xunit; |
| 10 | |
| 11 | public class AllUsersFixture |
| 12 | { |
| 13 | [Fact] |
| 14 | public void CanCheckPerMachineMsi() |
| 15 | { |
| 16 | var propertyRows = BuildAndQueryPropertyTable("PerMachine.wxs"); |
| 17 | |
| 18 | WixAssert.CompareLineByLine(new[] |
| 19 | { |
| 20 | "_SummaryInformation:WordCount\t2", |
| 21 | "Property:ALLUSERS\t1" |
| 22 | }, propertyRows); |
| 23 | } |
| 24 | |
| 25 | [Fact] |
| 26 | public void CanCheckPerUserMsi() |
| 27 | { |
| 28 | var propertyRows = BuildAndQueryPropertyTable("PerUser.wxs"); |
| 29 | |
| 30 | WixAssert.CompareLineByLine(new[] |
| 31 | { |
| 32 | "_SummaryInformation:WordCount\t10" |
| 33 | }, propertyRows); |
| 34 | } |
| 35 | |
| 36 | [Fact] |
| 37 | public void CanCheckPerUserOrMachineMsi() |
| 38 | { |
| 39 | var propertyRows = BuildAndQueryPropertyTable("PerUserOrMachine.wxs"); |
| 40 | |
| 41 | WixAssert.CompareLineByLine(new[] |
| 42 | { |
| 43 | "_SummaryInformation:WordCount\t2", |
| 44 | "Property:ALLUSERS\t2", |
| 45 | "Property:MSIINSTALLPERUSER\t1" |
| 46 | }, propertyRows); |
| 47 | } |
| 48 | |
| 49 | private static string[] BuildAndQueryPropertyTable(string file) |
| 50 | { |
| 51 | var folder = TestData.Get("TestData", "AllUsers"); |
| 52 | |
| 53 | using (var fs = new DisposableFileSystem()) |
| 54 | { |
| 55 | var baseFolder = fs.GetFolder(); |
| 56 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 57 | var binFolder = Path.Combine(baseFolder, "bin"); |
| 58 | var msiPath = Path.Combine(binFolder, "test.msi"); |
| 59 | |
| 60 | var result = WixRunner.Execute(new[] |
| 61 | { |
| 62 | "build", |
| 63 | Path.Combine(folder, file), |
| 64 | "-intermediateFolder", intermediateFolder, |
| 65 | "-bindpath", folder, |
| 66 | "-o", msiPath, |
| 67 | }); |
| 68 | result.AssertSuccess(); |
| 69 | |
| 70 | return Query.QueryDatabase(msiPath, new[] { "Property", "_SummaryInformation" }) |
| 71 | .Where(s => s.StartsWith("Property:ALLUSERS") || s.StartsWith("Property:MSIINSTALLPERUSER") || s.StartsWith("_SummaryInformation:WordCount")) |
| 72 | .OrderBy(s => s) |
| 73 | .ToArray(); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | } |