aboutsummaryrefslogtreecommitdiff
path: root/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs')
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs153
1 files changed, 0 insertions, 153 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs
deleted file mode 100644
index 089658e6..00000000
--- a/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs
+++ /dev/null
@@ -1,153 +0,0 @@
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 Example.Extension;
9 using WixBuildTools.TestSupport;
10 using WixToolset.Core.TestPackage;
11 using WixToolset.Data;
12 using WixToolset.Data.Symbols;
13 using Xunit;
14
15 public class ExtensionFixture
16 {
17 [Fact]
18 public void CanBuildAndQuery()
19 {
20 var folder = TestData.Get(@"TestData\ExampleExtension");
21 var build = new Builder(folder, typeof(ExampleExtensionFactory), new[] { Path.Combine(folder, "data") });
22
23 var results = build.BuildAndQuery(Build, "Wix4Example");
24 Assert.Equal(new[]
25 {
26 "Wix4Example:Foo\tBar"
27 }, results);
28 }
29
30 [Fact]
31 public void CanBuildWithExampleExtension()
32 {
33 var folder = TestData.Get(@"TestData\ExampleExtension");
34 var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
35
36 using (var fs = new DisposableFileSystem())
37 {
38 var intermediateFolder = fs.GetFolder();
39
40 var result = WixRunner.Execute(new[]
41 {
42 "build",
43 Path.Combine(folder, "Package.wxs"),
44 Path.Combine(folder, "PackageComponents.wxs"),
45 "-loc", Path.Combine(folder, "Package.en-us.wxl"),
46 "-ext", extensionPath,
47 "-bindpath", Path.Combine(folder, "data"),
48 "-intermediateFolder", intermediateFolder,
49 "-o", Path.Combine(intermediateFolder, @"bin\extest.msi")
50 });
51
52 result.AssertSuccess();
53
54 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\extest.msi")));
55 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\extest.wixpdb")));
56 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\PFiles\MsiPackage\example.txt")));
57
58 var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\extest.wixpdb"));
59 var section = intermediate.Sections.Single();
60
61 var fileSymbol = section.Symbols.OfType<FileSymbol>().Single();
62 Assert.Equal(Path.Combine(folder, @"data\example.txt"), fileSymbol[FileSymbolFields.Source].AsPath().Path);
63 Assert.Equal(@"example.txt", fileSymbol[FileSymbolFields.Source].PreviousValue.AsPath().Path);
64
65 var example = section.Symbols.Where(t => t.Definition.Type == SymbolDefinitionType.MustBeFromAnExtension).Single();
66 Assert.Equal("Foo", example.Id?.Id);
67 Assert.Equal("Bar", example[0].AsString());
68 }
69 }
70
71 [Fact]
72 public void CanParseCommandLineWithExtension()
73 {
74 var folder = TestData.Get(@"TestData\ExampleExtension");
75 var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath);
76
77 using (var fs = new DisposableFileSystem())
78 {
79 var intermediateFolder = fs.GetFolder();
80
81 var result = WixRunner.Execute(new[]
82 {
83 "build",
84 Path.Combine(folder, "Package.wxs"),
85 Path.Combine(folder, "PackageComponents.wxs"),
86 "-loc", Path.Combine(folder, "Package.en-us.wxl"),
87 "-ext", extensionPath,
88 "-bindpath", Path.Combine(folder, "data"),
89 "-intermediateFolder", intermediateFolder,
90 "-example", "test",
91 "-o", Path.Combine(intermediateFolder, @"bin\extest.msi")
92 });
93
94 result.AssertSuccess();
95
96 var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\extest.wixpdb"));
97 var section = intermediate.Sections.Single();
98
99 var property = section.Symbols.OfType<PropertySymbol>().Where(p => p.Id.Id == "ExampleProperty").Single();
100 Assert.Equal("ExampleProperty", property.Id.Id);
101 Assert.Equal("test", property.Value);
102 }
103 }
104
105 [Fact]
106 public void CannotBuildWithMissingExtension()
107 {
108 var folder = TestData.Get(@"TestData\ExampleExtension");
109
110 using (var fs = new DisposableFileSystem())
111 {
112 var intermediateFolder = fs.GetFolder();
113
114 var exception = Assert.Throws<WixException>(() =>
115 WixRunner.Execute(new[]
116 {
117 "build",
118 Path.Combine(folder, "Package.wxs"),
119 "-ext", "ExampleExtension.DoesNotExist"
120 }));
121
122 Assert.StartsWith("The extension 'ExampleExtension.DoesNotExist' could not be found. Checked paths: ", exception.Message);
123 }
124 }
125
126 [Fact]
127 public void CannotBuildWithMissingVersionedExtension()
128 {
129 var folder = TestData.Get(@"TestData\ExampleExtension");
130
131 using (var fs = new DisposableFileSystem())
132 {
133 var intermediateFolder = fs.GetFolder();
134
135 var exception = Assert.Throws<WixException>(() =>
136 WixRunner.Execute(new[]
137 {
138 "build",
139 Path.Combine(folder, "Package.wxs"),
140 "-ext", "ExampleExtension.DoesNotExist/1.0.0"
141 }));
142
143 Assert.StartsWith("The extension 'ExampleExtension.DoesNotExist/1.0.0' could not be found. Checked paths: ", exception.Message);
144 }
145 }
146
147 private static void Build(string[] args)
148 {
149 var result = WixRunner.Execute(args)
150 .AssertSuccess();
151 }
152 }
153}