aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-12-29 03:57:03 -0800
committerRob Mensching <rob@firegiant.com>2017-12-29 03:57:03 -0800
commitbe163ecb92398a8d569a7e97aaf25bc7e5fb9eec (patch)
treed720b23f90a7e9667a4480e11e8aac506f9a8250 /src
parent58b8be53fd966e3d475362912477a422f5b5aa11 (diff)
downloadwix-be163ecb92398a8d569a7e97aaf25bc7e5fb9eec.tar.gz
wix-be163ecb92398a8d569a7e97aaf25bc7e5fb9eec.tar.bz2
wix-be163ecb92398a8d569a7e97aaf25bc7e5fb9eec.zip
Move to WixBuildTools.TestSupport
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.BuildTasks/Properties/AssemblyInfo.cs7
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs30
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs8
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs86
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs46
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs17
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj8
7 files changed, 33 insertions, 169 deletions
diff --git a/src/WixToolset.BuildTasks/Properties/AssemblyInfo.cs b/src/WixToolset.BuildTasks/Properties/AssemblyInfo.cs
deleted file mode 100644
index ae52fce8..00000000
--- a/src/WixToolset.BuildTasks/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,7 +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
3using System.Reflection;
4using System.Runtime.InteropServices;
5
6[assembly: AssemblyCulture("")]
7[assembly: ComVisible(false)]
diff --git a/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs
index 3714f9e7..5de61368 100644
--- a/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/ExtensionFixture.cs
@@ -6,15 +6,28 @@ namespace WixToolsetTest.CoreIntegration
6 using System.IO; 6 using System.IO;
7 using System.Linq; 7 using System.Linq;
8 using Example.Extension; 8 using Example.Extension;
9 using WixBuildTools.TestSupport;
9 using WixToolset.Core; 10 using WixToolset.Core;
10 using WixToolset.Data; 11 using WixToolset.Data;
11 using WixToolset.Data.Tuples; 12 using WixToolset.Data.Tuples;
12 using WixToolsetTest.CoreIntegration.Utility;
13 using Xunit; 13 using Xunit;
14 14
15 public class ExtensionFixture 15 public class ExtensionFixture
16 { 16 {
17 [Fact] 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, "Example");
24 Assert.Equal(new[]
25 {
26 "Example:Foo\tBar"
27 }, results);
28 }
29
30 [Fact]
18 public void CanBuildWithExampleExtension() 31 public void CanBuildWithExampleExtension()
19 { 32 {
20 var folder = TestData.Get(@"TestData\ExampleExtension"); 33 var folder = TestData.Get(@"TestData\ExampleExtension");
@@ -83,21 +96,20 @@ namespace WixToolsetTest.CoreIntegration
83 96
84 Assert.Equal(0, result); 97 Assert.Equal(0, result);
85 98
86 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\extest.msi")));
87 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\extest.wixpdb")));
88 Assert.True(File.Exists(Path.Combine(intermediateFolder, @"bin\MsiPackage\example.txt")));
89
90 var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\extest.wir")); 99 var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"bin\extest.wir"));
91 var section = intermediate.Sections.Single(); 100 var section = intermediate.Sections.Single();
92 101
93 var wixFile = section.Tuples.OfType<WixFileTuple>().Single();
94 Assert.Equal(Path.Combine(folder, @"data\example.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path);
95 Assert.Equal(@"example.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path);
96
97 var property = section.Tuples.OfType<PropertyTuple>().Where(p => p.Id.Id == "ExampleProperty").Single(); 102 var property = section.Tuples.OfType<PropertyTuple>().Where(p => p.Id.Id == "ExampleProperty").Single();
98 Assert.Equal("ExampleProperty", property.Property); 103 Assert.Equal("ExampleProperty", property.Property);
99 Assert.Equal("test", property.Value); 104 Assert.Equal("test", property.Value);
100 } 105 }
101 } 106 }
107
108 private static void Build(string[] args)
109 {
110 var program = new Program();
111 var result = program.Run(new WixToolsetServiceProvider(), null, args);
112 Assert.Equal(0, result);
113 }
102 } 114 }
103} 115}
diff --git a/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs b/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs
index b4a7c8b2..7e54174d 100644
--- a/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/ProgramFixture.cs
@@ -4,11 +4,11 @@ namespace WixToolsetTest.CoreIntegration
4{ 4{
5 using System.IO; 5 using System.IO;
6 using System.Linq; 6 using System.Linq;
7 using WixBuildTools.TestSupport;
7 using WixToolset.Core; 8 using WixToolset.Core;
8 using WixToolset.Data; 9 using WixToolset.Data;
9 using WixToolset.Data.Tuples; 10 using WixToolset.Data.Tuples;
10 using WixToolset.Data.WindowsInstaller; 11 using WixToolset.Data.WindowsInstaller;
11 using WixToolsetTest.CoreIntegration.Utility;
12 using Xunit; 12 using Xunit;
13 13
14 public class ProgramFixture 14 public class ProgramFixture
@@ -247,7 +247,7 @@ namespace WixToolsetTest.CoreIntegration
247 } 247 }
248 248
249 [Fact] 249 [Fact]
250 public void CanBuildWixout() 250 public void CanBuildWixipl()
251 { 251 {
252 var folder = TestData.Get(@"TestData\SingleFile"); 252 var folder = TestData.Get(@"TestData\SingleFile");
253 253
@@ -265,7 +265,7 @@ namespace WixToolsetTest.CoreIntegration
265 "-loc", Path.Combine(folder, "Package.en-us.wxl"), 265 "-loc", Path.Combine(folder, "Package.en-us.wxl"),
266 "-bindpath", Path.Combine(folder, "data"), 266 "-bindpath", Path.Combine(folder, "data"),
267 "-intermediateFolder", intermediateFolder, 267 "-intermediateFolder", intermediateFolder,
268 "-o", Path.Combine(baseFolder, @"bin\test.wixout") 268 "-o", Path.Combine(baseFolder, @"bin\test.wixipl")
269 }); 269 });
270 270
271 Assert.Equal(0, result); 271 Assert.Equal(0, result);
@@ -273,7 +273,7 @@ namespace WixToolsetTest.CoreIntegration
273 var builtFiles = Directory.GetFiles(Path.Combine(baseFolder, @"bin")); 273 var builtFiles = Directory.GetFiles(Path.Combine(baseFolder, @"bin"));
274 274
275 Assert.Equal(new[]{ 275 Assert.Equal(new[]{
276 "test.wixout" 276 "test.wixipl"
277 }, builtFiles.Select(Path.GetFileName).ToArray()); 277 }, builtFiles.Select(Path.GetFileName).ToArray());
278 } 278 }
279 } 279 }
diff --git a/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs
deleted file mode 100644
index 795d344a..00000000
--- a/src/test/WixToolsetTest.CoreIntegration/Utility/DisposableFileSystem.cs
+++ /dev/null
@@ -1,86 +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.Utility
4{
5 using System;
6 using System.Collections.Generic;
7 using System.IO;
8
9 public class DisposableFileSystem : IDisposable
10 {
11 protected bool Disposed { get; private set; }
12
13 private List<string> CleanupPaths { get; } = new List<string>();
14
15 protected string GetFile(bool create = false)
16 {
17 var path = Path.GetTempFileName();
18
19 if (!create)
20 {
21 File.Delete(path);
22 }
23
24 this.CleanupPaths.Add(path);
25
26 return path;
27 }
28
29 public string GetFolder(bool create = false)
30 {
31 var path = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
32
33 if (create)
34 {
35 Directory.CreateDirectory(path);
36 }
37
38 this.CleanupPaths.Add(path);
39
40 return path;
41 }
42
43
44 #region // IDisposable
45
46 public void Dispose()
47 {
48 this.Dispose(true);
49 GC.SuppressFinalize(this);
50 }
51
52 protected virtual void Dispose(bool disposing)
53 {
54 if (this.Disposed)
55 {
56 return;
57 }
58
59 if (disposing)
60 {
61 foreach (var path in this.CleanupPaths)
62 {
63 try
64 {
65 if (File.Exists(path))
66 {
67 File.Delete(path);
68 }
69 else if (Directory.Exists(path))
70 {
71 Directory.Delete(path, true);
72 }
73 }
74 catch
75 {
76 // Best effort delete, so ignore any failures.
77 }
78 }
79 }
80
81 this.Disposed = true;
82 }
83
84 #endregion
85 }
86}
diff --git a/src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs
deleted file mode 100644
index efd733a7..00000000
--- a/src/test/WixToolsetTest.CoreIntegration/Utility/Pushd.cs
+++ /dev/null
@@ -1,46 +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.Utility
4{
5 using System;
6 using System.IO;
7
8 public class Pushd : IDisposable
9 {
10 protected bool Disposed { get; private set; }
11
12 public Pushd(string path)
13 {
14 this.PreviousDirectory = Directory.GetCurrentDirectory();
15
16 Directory.SetCurrentDirectory(path);
17 }
18
19 public string PreviousDirectory { get; }
20
21 #region // IDisposable
22
23 public void Dispose()
24 {
25 this.Dispose(true);
26 GC.SuppressFinalize(this);
27 }
28
29 protected virtual void Dispose(bool disposing)
30 {
31 if (this.Disposed)
32 {
33 return;
34 }
35
36 if (disposing)
37 {
38 Directory.SetCurrentDirectory(this.PreviousDirectory);
39 }
40
41 this.Disposed = true;
42 }
43
44 #endregion
45 }
46}
diff --git a/src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs b/src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs
deleted file mode 100644
index e3b21183..00000000
--- a/src/test/WixToolsetTest.CoreIntegration/Utility/TestData.cs
+++ /dev/null
@@ -1,17 +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.Utility
4{
5 using System;
6 using System.IO;
7
8 public class TestData
9 {
10 public static string LocalPath => Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);
11
12 public static string Get(params string[] paths)
13 {
14 return Path.Combine(LocalPath, Path.Combine(paths));
15 }
16 }
17}
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
index e4c2713c..d406a0da 100644
--- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
@@ -7,6 +7,10 @@
7 <IsPackable>false</IsPackable> 7 <IsPackable>false</IsPackable>
8 </PropertyGroup> 8 </PropertyGroup>
9 9
10 <PropertyGroup>
11 <NoWarn>NU1701</NoWarn>
12 </PropertyGroup>
13
10 <ItemGroup> 14 <ItemGroup>
11 <Content Include="TestData\SimpleModule\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> 15 <Content Include="TestData\SimpleModule\data\test.txt" CopyToOutputDirectory="PreserveNewest" />
12 <Content Include="TestData\SimpleModule\Module.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> 16 <Content Include="TestData\SimpleModule\Module.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
@@ -43,6 +47,10 @@
43 </ItemGroup> 47 </ItemGroup>
44 48
45 <ItemGroup> 49 <ItemGroup>
50 <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.*" />
51 </ItemGroup>
52
53 <ItemGroup>
46 <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" /> 54 <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
47 <PackageReference Include="xunit" Version="2.2.0" /> 55 <PackageReference Include="xunit" Version="2.2.0" />
48 <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> 56 <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />