2015-11-25 01:48:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
[assembly: CollectionBehavior(DisableTestParallelization = true)]
|
|
|
|
|
|
|
|
|
|
namespace Dotnet.Cli.Msi.Tests
|
|
|
|
|
{
|
|
|
|
|
public class InstallationTests : IDisposable
|
|
|
|
|
{
|
|
|
|
|
private MsiManager _msiMgr;
|
|
|
|
|
|
|
|
|
|
public InstallationTests()
|
|
|
|
|
{
|
|
|
|
|
// all the tests assume that the msi to be tested is available via environment variable %CLI_MSI%
|
2016-01-28 09:46:03 +00:00
|
|
|
|
var msiFile = Environment.GetEnvironmentVariable("CLI_MSI");
|
|
|
|
|
if(string.IsNullOrEmpty(msiFile))
|
2015-11-25 01:48:58 +00:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("%CLI_MSI% must point to the msi that is to be tested");
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-28 09:46:03 +00:00
|
|
|
|
_msiMgr = new MsiManager(msiFile);
|
2015-11-25 01:48:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-25 23:38:35 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void InstallTest()
|
2015-11-25 01:48:58 +00:00
|
|
|
|
{
|
2016-03-25 23:38:35 +00:00
|
|
|
|
string expectedInstallLocation = Environment.ExpandEnvironmentVariables(@"%ProgramFiles%\dotnet");
|
2015-11-25 01:48:58 +00:00
|
|
|
|
|
|
|
|
|
// 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");
|
|
|
|
|
Assert.False(Directory.Exists(expectedInstallLocation));
|
|
|
|
|
|
2016-03-25 23:38:35 +00:00
|
|
|
|
_msiMgr.Install();
|
2016-01-28 09:46:03 +00:00
|
|
|
|
Assert.True(_msiMgr.IsInstalled);
|
2015-11-25 01:48:58 +00:00
|
|
|
|
Assert.True(Directory.Exists(expectedInstallLocation));
|
|
|
|
|
|
|
|
|
|
_msiMgr.UnInstall();
|
|
|
|
|
Assert.False(_msiMgr.IsInstalled);
|
|
|
|
|
Assert.False(Directory.Exists(expectedInstallLocation));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
if (!_msiMgr.IsInstalled)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_msiMgr.UnInstall();
|
|
|
|
|
Assert.False(_msiMgr.IsInstalled, "Unable to cleanup by uninstalling dotnet");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|