dotnet-installer/packaging/windows/Dotnet.Cli.Msi.Tests/InstallFixture.cs
Sridhar Periyasamy e131be5aaa Unit tests for Dotnet MSI
- Needs a clean machine without dotnet MSI installed for the tests to run.
- Needs admin privileges to run. Else test script exits silently.
- These xunit based tests run on Netfx46.

For now these tests are disabled until I figure out the right way to run
them in the CI machines.
2015-11-24 17:48:58 -08:00

54 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Dotnet.Cli.Msi.Tests
{
public class InstallFixture : IDisposable
{
private MsiManager _msiMgr = null;
// all the tests assume that the msi to be tested is available via environment variable %CLI_MSI%
public InstallFixture()
{
string msiFile = Environment.GetEnvironmentVariable("CLI_MSI");
_msiMgr = new MsiManager(msiFile);
// make sure that the msi is not already installed, if so the machine is in a bad state
Assert.False(_msiMgr.IsInstalled, "The dotnet CLI msi is already installed");
_msiMgr.Install(InstallLocation);
Assert.True(_msiMgr.IsInstalled);
}
public MsiManager MsiManager
{
get
{
return _msiMgr;
}
}
public string InstallLocation
{
get
{
return Environment.ExpandEnvironmentVariables(@"%SystemDrive%\dotnet\");
}
}
public void Dispose()
{
if (!_msiMgr.IsInstalled)
{
return;
}
_msiMgr.UnInstall();
Assert.False(_msiMgr.IsInstalled, "Unable to cleanup by uninstalling dotnet");
}
}
}