aboutsummaryrefslogtreecommitdiff
path: root/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs')
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs
new file mode 100644
index 00000000..4568f93f
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs
@@ -0,0 +1,117 @@
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
3namespace WixToolsetTest.CoreIntegration
4{
5 using System;
6 using System.IO;
7 using System.Linq;
8 using WixBuildTools.TestSupport;
9 using WixToolset.Core.Burn.Bundles;
10 using WixToolset.Core.TestPackage;
11 using WixToolset.Data;
12 using WixToolset.Data.Symbols;
13 using Xunit;
14
15 public class PayloadFixture
16 {
17 [Fact]
18 public void CanParseValidName()
19 {
20 var folder = TestData.Get(@"TestData\Payload");
21
22 using (var fs = new DisposableFileSystem())
23 {
24 var baseFolder = fs.GetFolder();
25 var intermediateFolder = Path.Combine(baseFolder, "obj");
26 var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib");
27
28 var result = WixRunner.Execute(new[]
29 {
30 "build",
31 Path.Combine(folder, "ValidName.wxs"),
32 "-intermediateFolder", intermediateFolder,
33 "-o", wixlibPath,
34 });
35
36 result.AssertSuccess();
37
38 Assert.Empty(result.Messages);
39
40 var intermediate = Intermediate.Load(wixlibPath);
41 var allSymbols = intermediate.Sections.SelectMany(s => s.Symbols);
42 var payloadSymbol = allSymbols.OfType<WixBundlePayloadSymbol>()
43 .SingleOrDefault();
44 Assert.NotNull(payloadSymbol);
45
46 var fields = payloadSymbol.Fields.Select(field => field?.Type == IntermediateFieldType.Bool
47 ? field.AsNullableNumber()?.ToString()
48 : field?.AsString())
49 .ToList();
50 Assert.Equal(@"dir\file.ext", fields[(int)WixBundlePayloadSymbolFields.Name]);
51 }
52 }
53
54 [Fact]
55 public void CanCanonicalizeName()
56 {
57 var folder = TestData.Get(@"TestData\Payload");
58
59 using (var fs = new DisposableFileSystem())
60 {
61 var baseFolder = fs.GetFolder();
62 var intermediateFolder = Path.Combine(baseFolder, "obj");
63 var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib");
64
65 var result = WixRunner.Execute(new[]
66 {
67 "build",
68 Path.Combine(folder, "CanonicalizeName.wxs"),
69 "-intermediateFolder", intermediateFolder,
70 "-o", wixlibPath,
71 });
72
73 result.AssertSuccess();
74
75 Assert.Single(result.Messages, m => m.Id == (int)WarningMessages.Ids.PathCanonicalized);
76
77 var intermediate = Intermediate.Load(wixlibPath);
78 var allSymbols = intermediate.Sections.SelectMany(s => s.Symbols);
79 var payloadSymbol = allSymbols.OfType<WixBundlePayloadSymbol>()
80 .SingleOrDefault();
81 Assert.NotNull(payloadSymbol);
82
83 var fields = payloadSymbol.Fields.Select(field => field?.Type == IntermediateFieldType.Bool
84 ? field.AsNullableNumber()?.ToString()
85 : field?.AsString())
86 .ToList();
87 Assert.Equal(@"c\d.exe", fields[(int)WixBundlePayloadSymbolFields.Name]);
88 }
89 }
90
91 [Fact]
92 public void RejectsAbsoluteName()
93 {
94 var folder = TestData.Get(@"TestData\Payload");
95
96 using (var fs = new DisposableFileSystem())
97 {
98 var baseFolder = fs.GetFolder();
99 var intermediateFolder = Path.Combine(baseFolder, "obj");
100 var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib");
101
102 var result = WixRunner.Execute(new[]
103 {
104 "build",
105 Path.Combine(folder, "AbsoluteName.wxs"),
106 "-intermediateFolder", intermediateFolder,
107 "-o", wixlibPath,
108 });
109
110 Assert.InRange(result.ExitCode, 2, int.MaxValue);
111
112 Assert.Equal(1, result.Messages.Where(m => m.Id == (int)ErrorMessages.Ids.IllegalRelativeLongFilename).Count());
113 Assert.Equal(2, result.Messages.Where(m => m.Id == (int)ErrorMessages.Ids.PayloadMustBeRelativeToCache).Count());
114 }
115 }
116 }
117}