@joebigelow / wix-1 / commits / 220bea19

Tests for CopyFile element

Validates wixtoolset/issues#5867

Rob Mensching committed Jul 8, 2020 at 13:09 UTC 220bea1948c19132d0e5277021b967993293c5a3
3 files changed +64
src/test/WixToolsetTest.CoreIntegration/CopyFileFixture.cs new
+48
@@ -0,0 +1,48 @@
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 WixBuildTools.TestSupport;
8 + using WixToolset.Core.TestPackage;
9 + using WixToolset.Data;
10 + using WixToolset.Data.Symbols;
11 + using Xunit;
12 +
13 + public class CopyFileFixture
14 + {
15 + [Fact]
16 + public void CanBuildCopyFile()
17 + {
18 + var folder = TestData.Get(@"TestData");
19 +
20 + using (var fs = new DisposableFileSystem())
21 + {
22 + var baseFolder = fs.GetFolder();
23 + var intermediateFolder = Path.Combine(baseFolder, "obj");
24 + var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
25 +
26 + var result = WixRunner.Execute(new[]
27 + {
28 + "build",
29 + Path.Combine(folder, "CopyFile", "CopyFile.wxs"),
30 + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
31 + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
32 + "-bindpath", Path.Combine(folder, "SingleFile", "data"),
33 + "-intermediateFolder", intermediateFolder,
34 + "-o", msiPath
35 + });
36 +
37 + result.AssertSuccess();
38 +
39 + var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"bin\test.wixpdb"));
40 + var section = intermediate.Sections.Single();
41 + var copyFileSymbol = section.Symbols.OfType<MoveFileSymbol>().Single();
42 + Assert.Equal("MoveText", copyFileSymbol.Id.Id);
43 + Assert.True(copyFileSymbol.Delete);
44 + Assert.Equal("OtherFolder", copyFileSymbol.DestFolder);
45 + }
46 + }
47 + }
48 +}
src/test/WixToolsetTest.CoreIntegration/TestData/CopyFile/CopyFile.wxs new
+15
@@ -0,0 +1,15 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Fragment>
4 + <ComponentGroup Id="ProductComponents">
5 + <Component Id="CopyFileComp" Directory="INSTALLFOLDER">
6 + <File Id="test.txt" Source="test.txt" />
7 + <CopyFile Id="MoveText" Delete="yes" SourceName="*.txt" DestinationDirectory="OtherFolder"/>
8 + </Component>
9 + </ComponentGroup>
10 + </Fragment>
11 +
12 + <Fragment>
13 + <Directory Id="OtherFolder" Name="INSTALLFOLDER:\other" />
14 + </Fragment>
15 +</Wix>
src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+1
@@ -33,6 +33,7 @@
33 <Content Include="TestData\Class\DecompiledOldClassTableDef.wxs" CopyToOutputDirectory="PreserveNewest" />
34 <Content Include="TestData\Class\IconIndex0.wxs" CopyToOutputDirectory="PreserveNewest" />
35 <Content Include="TestData\Class\OldClassTableDef.msi" CopyToOutputDirectory="PreserveNewest" />
36 + <Content Include="TestData\CopyFile\CopyFile.wxs" CopyToOutputDirectory="PreserveNewest" />
37 <Content Include="TestData\CustomAction\CustomActionCycle.wxs" CopyToOutputDirectory="PreserveNewest" />
38 <Content Include="TestData\CustomAction\UnscheduledCustomAction.wxs" CopyToOutputDirectory="PreserveNewest" />
39 <Content Include="TestData\CustomTable\CustomTable-Expected.wxs" CopyToOutputDirectory="PreserveNewest" />