aboutsummaryrefslogtreecommitdiff
path: root/src/test/dtf/SampleCA
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-07-19 15:17:10 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-07-20 08:53:56 -0500
commit913b6238417dceeb8440315e4669990756d17655 (patch)
treea9e3552ea124d2025e30436afc8629f071c01ed4 /src/test/dtf/SampleCA
parent93bb820eff547f8de304f05249f572da861256fb (diff)
downloadwix-913b6238417dceeb8440315e4669990756d17655.tar.gz
wix-913b6238417dceeb8440315e4669990756d17655.tar.bz2
wix-913b6238417dceeb8440315e4669990756d17655.zip
Add WixInternalUIBootstrapperApplication as a new built-in BA.
Implements 6835
Diffstat (limited to 'src/test/dtf/SampleCA')
-rw-r--r--src/test/dtf/SampleCA/CustomAction.config10
-rw-r--r--src/test/dtf/SampleCA/SampleCA.cs125
-rw-r--r--src/test/dtf/SampleCA/SampleCA.csproj16
-rw-r--r--src/test/dtf/SampleCA/testsub/testfile.txt1
4 files changed, 0 insertions, 152 deletions
diff --git a/src/test/dtf/SampleCA/CustomAction.config b/src/test/dtf/SampleCA/CustomAction.config
deleted file mode 100644
index 700aff6f..00000000
--- a/src/test/dtf/SampleCA/CustomAction.config
+++ /dev/null
@@ -1,10 +0,0 @@
1<?xml version="1.0" encoding="utf-8" ?>
2<!-- 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. -->
3
4
5<configuration>
6 <startup useLegacyV2RuntimeActivationPolicy="true">
7 <supportedRuntime version="v4.0" />
8 <supportedRuntime version="v2.0.50727" />
9 </startup>
10</configuration>
diff --git a/src/test/dtf/SampleCA/SampleCA.cs b/src/test/dtf/SampleCA/SampleCA.cs
deleted file mode 100644
index fc9f30fe..00000000
--- a/src/test/dtf/SampleCA/SampleCA.cs
+++ /dev/null
@@ -1,125 +0,0 @@
1namespace WixToolset.Samples
2{
3 using System;
4 using System.Collections.Generic;
5 using System.IO;
6 using WixToolset.Dtf.WindowsInstaller;
7
8 public class SampleCA
9 {
10 [CustomAction]
11 public static ActionResult SampleCA1(Session session)
12 {
13 using (Record msgRec = new Record(0))
14 {
15 msgRec[0] = "Hello from SampleCA1!" +
16 "\r\nCLR version is v" + Environment.Version;
17 session.Message(InstallMessage.Info, msgRec);
18 session.Message(InstallMessage.User, msgRec);
19 }
20
21 session.Log("Testing summary info...");
22 SummaryInfo summInfo = session.Database.SummaryInfo;
23 session.Log("MSI PackageCode = {0}", summInfo.RevisionNumber);
24 session.Log("MSI ModifyDate = {0}", summInfo.LastSaveTime);
25
26 string testProp = session["SampleCATest"];
27 session.Log("Simple property test: [SampleCATest]={0}.", testProp);
28
29 session.Log("Testing subdirectory extraction...");
30 string testFilePath = "testsub\\SampleCAs.cs";
31 if (!File.Exists(testFilePath))
32 {
33 session.Log("Subdirectory extraction failed. File not found: " + testFilePath);
34 return ActionResult.Failure;
35 }
36 else
37 {
38 session.Log("Found file extracted in subdirectory.");
39 }
40
41 session.Log("Testing record stream extraction...");
42 string tempFile = null;
43 try
44 {
45 tempFile = Path.GetTempFileName();
46 using (View binView = session.Database.OpenView(
47 "SELECT `Binary`.`Data` FROM `Binary`, `CustomAction` " +
48 "WHERE `CustomAction`.`Target` = 'SampleCA1' AND " +
49 "`CustomAction`.`Source` = `Binary`.`Name`"))
50 {
51 binView.Execute();
52 using (Record binRec = binView.Fetch())
53 {
54 binRec.GetStream(1, tempFile);
55 }
56 }
57
58 session.Log("CA binary file size: {0}", new FileInfo(tempFile).Length);
59 string binFileVersion = Installer.GetFileVersion(tempFile);
60 session.Log("CA binary file version: {0}", binFileVersion);
61 }
62 finally
63 {
64 if (tempFile != null && File.Exists(tempFile))
65 {
66 File.Delete(tempFile);
67 }
68 }
69
70 session.Log("Testing record stream reading...");
71 using (View binView2 = session.Database.OpenView("SELECT `Data` FROM `Binary` WHERE `Name` = 'TestData'"))
72 {
73 binView2.Execute();
74 using (Record binRec2 = binView2.Fetch())
75 {
76 Stream stream = binRec2.GetStream("Data");
77 string testData = new StreamReader(stream, System.Text.Encoding.UTF8).ReadToEnd();
78 session.Log("Test data: " + testData);
79 }
80 }
81
82 session.Log("Listing components");
83 using (View compView = session.Database.OpenView(
84 "SELECT `Component` FROM `Component`"))
85 {
86 compView.Execute();
87 foreach (Record compRec in compView)
88 {
89 using (compRec)
90 {
91 session.Log("\t{0}", compRec["Component"]);
92 }
93 }
94 }
95
96 session.Log("Testing the ability to access an external MSI database...");
97 string tempDbFile = Path.GetTempFileName();
98 using (Database tempDb = new Database(tempDbFile, DatabaseOpenMode.CreateDirect))
99 {
100 // Just create an empty database.
101 }
102 using (Database tempDb2 = new Database(tempDbFile))
103 {
104 // See if we can open and query the database.
105 IList<string> tables = tempDb2.ExecuteStringQuery("SELECT `Name` FROM `_Tables`");
106 session.Log("Found " + tables.Count + " tables in the newly created database.");
107 }
108 File.Delete(tempDbFile);
109
110 return ActionResult.Success;
111 }
112
113 [CustomAction("SampleCA2")]
114 public static ActionResult SampleCustomAction2(Session session)
115 {
116 using (Record msgRec = new Record(0))
117 {
118 msgRec[0] = "Hello from SampleCA2!";
119 session.Message(InstallMessage.Info, msgRec);
120 session.Message(InstallMessage.User, msgRec);
121 }
122 return ActionResult.UserExit;
123 }
124 }
125}
diff --git a/src/test/dtf/SampleCA/SampleCA.csproj b/src/test/dtf/SampleCA/SampleCA.csproj
deleted file mode 100644
index 866b7575..00000000
--- a/src/test/dtf/SampleCA/SampleCA.csproj
+++ /dev/null
@@ -1,16 +0,0 @@
1<Project Sdk="Microsoft.NET.Sdk">
2 <PropertyGroup>
3 <TargetFramework>net20</TargetFramework>
4 <Description>Sample managed custom actions</Description>
5 </PropertyGroup>
6
7 <ItemGroup>
8 <Content Include="CustomAction.config" CopyToOutputDirectory="PreserveNewest" />
9 <None Include="testsub\testfile.txt" CopyToOutputDirectory="PreserveNewest" />
10 <CustomActionContents Include="testsub\SampleCAs.cs=$(OutputDirectory)testsub\testfile.txt" />
11 </ItemGroup>
12
13 <ItemGroup>
14 <PackageReference Include="WixToolset.Dtf.CustomAction" />
15 </ItemGroup>
16</Project>
diff --git a/src/test/dtf/SampleCA/testsub/testfile.txt b/src/test/dtf/SampleCA/testsub/testfile.txt
deleted file mode 100644
index 8056aefd..00000000
--- a/src/test/dtf/SampleCA/testsub/testfile.txt
+++ /dev/null
@@ -1 +0,0 @@
1test file for testing subdirectory support and binary stream reading