// 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.
namespace WixToolsetTest.Heat
{
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WixInternal.MSTestSupport;
[TestClass]
public class HeatFixture
{
[TestMethod]
public void CanHarvestSimpleDirectory()
{
var folder = TestData.Get("TestData", "SingleFile");
using (var fs = new DisposableFileSystem())
{
var outputPath = Path.Combine(fs.GetFolder(), "out.wxs");
var args = new[]
{
"dir", folder,
"-o", outputPath
};
var result = HeatRunner.Execute(args);
result.AssertSuccess();
var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray();
WixAssert.CompareLineByLine(new[]
{
"",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"",
}, wxs);
}
}
[TestMethod]
public void CanHarvestSimpleDirectoryToComponentGroup()
{
var folder = TestData.Get("TestData", "SingleFile");
using (var fs = new DisposableFileSystem())
{
var outputPath = Path.Combine(fs.GetFolder(), "out.wxs");
var args = new[]
{
"dir", folder,
"-cg", "CG1",
"-o", outputPath
};
var result = HeatRunner.Execute(args);
result.AssertSuccess();
var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray();
WixAssert.CompareLineByLine(new[]
{
"",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"",
}, wxs);
}
}
[TestMethod]
public void CanHarvestSimpleDirectoryToInstallFolder()
{
var folder = TestData.Get("TestData", "SingleFile");
using (var fs = new DisposableFileSystem())
{
var outputPath = Path.Combine(fs.GetFolder(), "out.wxs");
var args = new[]
{
"dir", folder,
"-dr", "INSTALLFOLDER",
"-indent", "2",
"-o", outputPath
};
var result = HeatRunner.Execute(args);
result.AssertSuccess();
var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray();
WixAssert.CompareLineByLine(new[]
{
"",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"",
}, wxs);
}
}
[TestMethod]
public void CanHarvestFile()
{
var folder = TestData.Get("TestData", "SingleFile");
using (var fs = new DisposableFileSystem())
{
var outputPath = Path.Combine(fs.GetFolder(), "out.wxs");
var args = new[]
{
"file", Path.Combine(folder, "a.txt"),
"-cg", "GroupA",
"-dr", "ProgramFiles6432Folder",
"-o", outputPath
};
var result = HeatRunner.Execute(args);
result.AssertSuccess();
var wxs = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray();
WixAssert.CompareLineByLine(new[]
{
"",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
"",
}, wxs);
}
}
[TestMethod]
public void CanHarvestRegistry()
{
var folder = TestData.Get("TestData", "RegFile");
using (var fs = new DisposableFileSystem())
{
var outputPath = Path.Combine(fs.GetFolder(), "out.wxs");
var args = new[]
{
"reg", Path.Combine(folder, "input.reg"),
"-o", outputPath
};
var result = HeatRunner.Execute(args);
result.AssertSuccess();
var actual = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray();
var expected = File.ReadAllLines(Path.Combine(folder, "Expected.wxs")).Select(s => s.Replace("\"", "'")).ToArray();
WixAssert.CompareLineByLine(expected, actual);
}
}
[TestMethod]
public void CanHarvestRegistryIntoComponentGroup()
{
var folder = TestData.Get("TestData", "RegFile");
using (var fs = new DisposableFileSystem())
{
var outputPath = Path.Combine(fs.GetFolder(), "out.wxs");
var args = new[]
{
"reg", Path.Combine(folder, "input.reg"),
"-cg", "CG1",
"-o", outputPath
};
var result = HeatRunner.Execute(args);
result.AssertSuccess();
var actual = File.ReadAllLines(outputPath).Select(s => s.Replace("\"", "'")).ToArray();
var expected = File.ReadAllLines(Path.Combine(folder, "ExpectedWithComponentGroup.wxs")).Select(s => s.Replace("\"", "'")).ToArray();
WixAssert.CompareLineByLine(expected, actual);
}
}
}
}